http://fzl-x.com/index.php?fromuid=28

在使用打开对话框时我可以得到FileName属性,但得到的是完整的路径。

例如:D:\other project\Data\text.mxd

但我有的时候只是需要所选择文件的文件名称,而不要前面的路径;

或是只需要前面的路径而不要文件名称。


using system.io.path

string fullPath ;
fullPath = Path.GetDirectoryName(OpenFileDialog1.FileName)
string fullName;
fullName = Path.GetFileName(OpenFileDialog1.FileName);

这样就完整了,呵呵

相关文章: