So I am wondering how do I get the directory of a file.
So if I want to find the directory of C:\Directory\myfile.txt
I would get C:\Directory
How can I do this?
CodePudding user response:
You can use the Path.GetDirectoryName
method
var dirname = Path.GetDirectoryName(filename);
this will output C:\Directory
Don't forget to add the using System.IO