日期:2014-05-20  浏览次数:20843 次

[C#]获取文件夹的名称
C# code

FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            
            if(folderBrowserDialog.ShowDialog(this) == DialogResult.OK)
            {
                fullDirectoryName = folderBrowserDialog.SelectedPath;
                directoryName = Path.GetDirectoryName(fullDirectoryName);
                this.txt_DireName.Text = fullDirectoryName;
            }


我用的是vs2003,GetDirectoryName方法的返回值怎么不是文件夹名称?
应该怎么获取绝对路径的文件夹的名称?
谢谢~~

------解决方案--------------------
C# code
this.txt_DireName.Text = new System.IO.DirectoryInfo(folderBrowserDialog.SelectedPath).Name;

------解决方案--------------------
DirectoryInfo 类的操作