0

گرفتن یک فایل از طریق دیالوگ OpenFileDialog و دستک

 
hosseinb68
hosseinb68
کاربر طلایی1
تاریخ عضویت : بهمن 1389 
تعداد پست ها : 1269
محل سکونت : بوشهر

گرفتن یک فایل از طریق دیالوگ OpenFileDialog و دستک
سه شنبه 7 آذر 1391  7:53 AM

01.using system.io;
02.OpenFileDialog openFile = new OpenFileDialog();
03.if (openFile.ShowDialog() != DialogResult.OK)
04.    return;
05.  
06.// get filename from OpenFileDialog
07.string fileName = openFile.FileName;
08.  
09.// get only filename without extension and path
10.string onlyname = Path.GetFileNameWithoutExtension(fileName);
11.  
12.// get extension of filename
13.string extension = Path.GetExtension(fileName);
14.  
15.// get directory of specific filename
16.string directory = Path.GetDirectoryName(fileName);
17.  
18.// change the extension of specific filename
19.string newFileName = Path.ChangeExtension(fileName, "bmp");
20.  
21.// get the root partition of specific file
22.string root = Path.GetPathRoot(fileName);

 

تشکرات از این پست
kaka a_sadri
دسترسی سریع به انجمن ها