C# C# Streams and Data Processing Reading Data Console I/O

Richard Oden
Richard Oden
12,878 Points

Why not use currentDirectory instead of directory.FullName for Path.Combine?

In the video, Carling first uses Directory.GetCurrentDirectory() to get a string containing directory's path. She then uses this string to make a DirectoryInfo object and uses its FullName property, which is also a string containing the path.

Could you not just use currentDirectory directly inside Path.Combine and cut out the middle man?

string currentDirectory = Directory.GetCurrentDirectory();
var fileName = Path.Combine(currentDirectory, "data.txt");
Reggie Williams
Reggie Williams
Treehouse Teacher

Richard Oden it looks like that should be a working solution as well but I believe Carlings solution is intended to introduce the DirectoryInfo class