日期:2014-05-18  浏览次数:20745 次

获取文件夹路径问题
代码

  FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
  folderBrowserDialog1.SelectedPath = @"D:";
  folderBrowserDialog1.Description = "请选择输出目录";

  DialogResult dialogResult = this.folderBrowserDialog1.ShowDialog();
  if (dialogResult == DialogResult.OK)
  {
  this.strBackUpPath = folderBrowserDialog1.SelectedPath;
  if(this.strBackUpPath == null)
  {
  MessageBox.Show("数据备份路径为空");
  return;
  }
  }

为什么不能获得指定路径呢?请大家帮忙

------解决方案--------------------
if(this.strBackUpPath == null)
=>
if(this.strBackUpPath == "")
------解决方案--------------------
string.IsNullOrEmpty(this.strBackUpPath)
{
 MessageBox.Show("数据备份路径为空");
return;
}
else
{
//your code
}