OpenFileDialog openFile = new OpenFileDialog();
if (openFile.ShowDialog() != DialogResult.OK)
{
return;
}
// get filename from OpenFileDialog آدرس کامل
string fileName = openFile.FileName;
// get only filename without extension and path فقط اسم فایل
string onlyname = Path.GetFileNameWithoutExtension(fileName);
// get extension of filename فقط فرمت فایل
string extension = Path.GetExtension(fileName);
// get directory of specific filename مسیر فایل بدون نام فایل ( اون چیزی که شما می خواید این هستش )
string directory = Path.GetDirectoryName(fileName);
// change the extension of specific filename تفییر فرمت
string newFileName = Path.ChangeExtension(fileName, "bmp");
// get the root partition of specific file فقط درایوی که فایل در آن قرار دارد
string root = Path.GetPathRoot(fileName);