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. }
04-30 09:00