把内容过程经常用到的一些内容片段收藏起来,如下的内容内容是关于C# WPF中调用打开文件对话框的内容。
private string OpenDialog()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "选择文件";
openFileDialog.FileName = string.Empty;
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
openFileDialog.DefaultExt = "txt";
if(openFileDialog.ShowDialog()==true)
{
return openFileDialog.FileName;
}else
{
return "";
}
}
原文地址:https://blog.51cto.com/14393435/2430351
时间: 2024-11-05 14:48:40