且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

System.Windows.Forms.OpenFileD ...

更新时间:2023-12-06 14:22:34

嗯......它可能确实有效。

它只是... ASP.NET暗示这是一个Web系统(正如您需要显式的System.Windows.Forms参考)。所以这将在服务器上打开一个对话框......如果可以的话。你的客户根本看不到它......



当然,当我将你的代码复制并粘贴到WinForms应用程序中时,它可以正常工作。


我应该使用FileUpload控件,因为它是ASP.Net应用程序。感谢。

After a button click, it hits the code below:

System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
openFileDialog1.Title = "Please Select a File";
openFileDialog1.InitialDirectory = "C:temp";
openFileDialog1.ShowDialog();


But openFileDialog1.ShowDialog(); does not work. No new window pops out and the debugging stops there. What's the possible reason? Thanks if you can share your experience.

Well...it probably does work, in fact.
It's just...ASP.NET implies this is a web system (as does you need for an explicit System.Windows.Forms reference). So this will open a dialog...on the server, if it can. Your client won't see it at all...

Certainly, when I copy and paste your code into a WinForms application it works fine.


I should use FileUpload control since it is ASP.Net application. Thanks.