get the directory of a file path c# code example
Example 1: get directory of file c#
using System.IO;
string file = "C:\Documents\file.txt";
Path.GetDirectoryName(file);
Example 2: c# get folder path from file path
Path.GetDirectoryName(filename);