VitzzViperzz
Well-known member
Hello,
I was just writing some code that would connect to a file in the directory of the application and I came across this line of code and I was curious to know what it does.
I can understand that we started by checking to see if the file path exists, then we go to say by using the streamer create a new path. Then we are saying that while Sr is not equal to the end of the stream the result should Sr ReadLine().
This is where I got very confused after (after the While statement)
Here is my code:
The code above was written in a class.
I hope this is clear and easy to understand.
Cheers,
I was just writing some code that would connect to a file in the directory of the application and I came across this line of code and I was curious to know what it does.
I can understand that we started by checking to see if the file path exists, then we go to say by using the streamer create a new path. Then we are saying that while Sr is not equal to the end of the stream the result should Sr ReadLine().
This is where I got very confused after (after the While statement)
Here is my code:
public void ReadFile() { List<Staff> myStaff = new List<Staff>(); string[] Result = new string[2]; string Path = "Staff.txt"; string[] Separator = { ", " }; if (File.Exists(Path)) { using (StreamReader sr = new StreamReader(Path)) { while (!sr.EndOfStream) { Result = sr.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries); } } }
The code above was written in a class.
I hope this is clear and easy to understand.
Cheers,