For example, I have the file addresses:
C: /windows/x.exe
C: /windwos/system32/example.exe
I would like to replace the filename and extension with "", thus:
C: / Windows /
C: / windows / system32 /
For example, I have the file addresses:
C: /windows/x.exe
C: /windwos/system32/example.exe
I would like to replace the filename and extension with "", thus:
C: / Windows /
C: / windows / system32 /
You can use the Path.GetDirectoryName method
var path1 = @"C:/windows/x.exe";
var path2 = @"C:/windwos/system32/exemplo.exe";
Console.WriteLine(Path.GetDirectoryName(path1) + Path.DirectorySeparatorChar);
Console.WriteLine(Path.GetDirectoryName(path2) + Path.DirectorySeparatorChar);