C# C# Streams and Data Processing Reading Data Breaking It Up Into Lines

Aaron Selonke
Aaron Selonke
10,323 Points

Why do we need to use the DirectoryInfo class?

There were a lot of new classes that I've not been familar with, so I was researching them one by one.

            string currentDirectory = Directory.GetCurrentDirectory();
            DirectoryInfo directory = new DirectoryInfo(currentDirectory);

            var fileName = Path.Combine(directory.FullName, "SoccerGameResults.csv");
            var fileContents = ReadFile(fileName);

It looks like in the code we wrote directory.FullName returns a string and is identical to the string currentDirectory.
That is, so far as I can tell, we didn't need to make the DirectoryInfo object at all.

2 Answers

Steven Parker
Steven Parker
177,655 Points

Is the directory not also used for other things later in the code? If not, you may have found a bug! :beetle:

You might want to submit this using the instructions on the Support page.

I also notice that there wasn't a need to use the DirectoryInfo class. Although I know that using DirectoryInfo gives us lots of instance methods, they were not used in the video.

Using Directory.GetCurrentDirectory() was sufficient to get the working directory path.

It did confuse/clutter things a bit.