本文介绍了基于单击按钮的“打开文件"对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
感谢所有共享代码的人.但是当我使用openfiledialog
时,我将面临foll异常
必须先将当前线程设置为单线程单元(STA)模式,然后才能进行OLE调用.
确保您的Main函数上已标记STAThreadAttribute.仅当
调试器已附加到该进程中."
在此先感谢
Thanks to all who shared code. but I''m facing the foll exception when I use openfiledialog
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made.
Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a
debugger is attached to the process"
Thanks in advance
推荐答案
objOpenFileDialog.Filter = "Excel files|*.xls;*.xlsx";
OpenFileDialog fileD = new OpenFileDialog(); //create object
fileD.Filter = "Excel files|*.xls;*.xlsx"; //define filter
fileD.ShowDialog(); //show dialog
MessageBox.show(fileD.fileName); //Get uploaded file
这篇关于基于单击按钮的“打开文件"对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!