【问题标题】:Selecting a word document file using openfiledialog使用 openfiledialog 选择 word 文档文件
【发布时间】:2014-11-11 11:31:54
【问题描述】:

我在使用 OpenFileDialog 选择 MS Word 文档时遇到问题。当我按下打开按钮时,它会将一些不需要的文档与 word 应用程序相关联。不知何故,我设法知道 Normal.dotm 和 NormalEmail.dotm 正在被访问。我不知道为什么?

我的 OpenFileDialog 代码是

this.openFileDialog.Filter = "Text Files (.txt)|*.txt|Word Documents (.docx)|*.docx|Word Template (.dotx)|*.dotx|All Files (*.*)|*.*";
openFileDialog.ValidateNames = true;
openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
    this.TextBoxTemplate.Text = openFileDialog.FileName;
}

【问题讨论】:

    标签: c# add-in openfiledialog


    【解决方案1】:

    刚刚找到解决方案。如果启用了文件预览窗格,则 OpenFileDialog 在其 FileOk 事件中启动一个新的 word 应用程序实例。因此,只需禁用预览窗格并消除故障。谢谢

    【讨论】:

      猜你喜欢
      • 2013-09-21
      • 2012-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多