新文章

2013年1月1日 星期二

[C#]Get the file name from file path


We can use OpenFileDialog.FileName to get file path easily.


But,how can we do to get the file name?

There is a good function to do this work.
If the SourceFilename is C:\Users\Hacks\Downloads\text.txt

String fileName = Path.GetFileNameWithoutExtension(SourceFilename);
And the fileName is "text".

沒有留言:

張貼留言