Get directory path of file path
string filePath = @"C:MyDirMySubDirmyfile.ext";
string directoryName = Path.GetDirectoryName(filePath);
Console.WriteLine($"GetDirectoryName('{filePath}') returns '{directoryName}'");
//This code produce the following output:
GetDirectoryName('C:MyDirMySubDirmyfile.ext') returns 'C:MyDirMySubDir'