string exePath = AppDomain.CurrentDomain.BaseDirectory;
// returns the directory where the .exe is located
string filename = @"C:/folder1/folder2/file.txt";
string FolderName = new DirectoryInfo(System.IO.Path.GetDirectoryName(filename)).Name;
String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Path.GetDirectoryName(filename);
OpenFileDialog choofdlog = new OpenFileDialog();
choofdlog.Filter = "All Files (*.*)|*.*";
choofdlog.FilterIndex = 1;
choofdlog.Multiselect = true;
if (choofdlog.ShowDialog() == DialogResult.OK)
{
string sFileName = choofdlog.FileName;
string[] arrAllFiles = choofdlog.FileNames; //used when Multiselect = true
}
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.Description = "Custom Description";
if (fbd.ShowDialog() == DialogResult.OK)
{
string sSelectedPath = fbd.SelectedPath;
}
string fileName = @"test.txt";
string currentDirectory = Directory.GetCurrentDirectory();
string[] fullFilePath = Directory.GetFiles(currentDirectory, filename, SearchOption.AllDirectories);