C#打开指定路径文件对话框

  1. private string OpenFileDlog(string DeafultDir)
  2. {
  3. OpenFileDialog Ofd = new OpenFileDialog();
  4. Ofd.AddExtension = true;
  5. Ofd.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*";
  6. Ofd.InitialDirectory = DeafultDir.Trim() == "" ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : DeafultDir;
  7. try
  8. {
  9. Ofd.ShowDialog();
  10. }
  11. catch { }
  12. if (Ofd.FileName == null || Ofd.FileName.Trim() == "")
  13. return DeafultDir;
  14. else
  15. return Ofd.FileName;
  16. }
上一篇:Ubuntu14.04.3,apt-get出现dpkg: error processing package xxx (--configure)和cups-daemon错误的解决方案


下一篇:POJ 2154 【POLYA】【欧拉】