把内容过程经常用到的一些内容片段收藏起来,如下的内容内容是关于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 "";
    }
}