日期:2014-05-18 浏览次数:20930 次
string path = @"c:\a\b\c\a.txt "; FileInfo fi = new FileInfo(path); DirectoryInfo di = fi.Directory; MessageBox.Show(di.Name);
------解决方案--------------------
string s = @"c:\a\b\c\a.txt ";
string[] dir = System.IO.Path.GetDirectoryName(s).Split(System.IO.Path.DirectorySeparatorChar);
MessageBox.Show(dir[dir.Length - 1]);