首页 > 技术文章 > C#一些代码小结--文件对话框

memorypro 2019-03-22 16:12 原文

C# 一些代码小结--文件对话框

查看文件完整路径
 try
 {
     Config cfg = new Config();
     var file = "";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         file = saveFileDialog1.FileName;//(获取整个文件名)
         cfg.WriteConfigFile(command, file);
         MessageBox.Show("file:" + file);
     }
 }
catch (Exception)
{
    OutputMessage("检查软件路径下面是否有\"Newtonsoft.Json.dll\"文件");
}
设置过滤器
this.openFileDialog1.Filter = "Json文件|*.json";

推荐阅读