我们可以在我的Web应用程序中使用System.Windows.Forms中提供的OpenFileDialog来浏览并获取所选访问数据库文件的完整路径,以便我可以导入该文件的数据。我实际上在本地实现了这个,但不确定它是否可以在现场工作。请建议。 我尝试了什么: 我实际实施了本地成功使用: public string getSelectedfilePath() { string str = string.Empty; System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Title =选择数据库文件; openFileDialog.InitialDirectory = C:\\; openFileDialog.Filter =访问数据库文件(* .mdb,* .accdb)| * .mdb; * .accdb |所有文件(*。*) | *。*; openFileDialog.RestoreDirectory = true; if(openFileDialog.ShowDialog()== System.Windows.Forms.DialogResult.OK) { str = Convert.ToString(openFileDialog.FileName); } return str; } 但不确定它是否可以在现场使用。请建议。
Can we use OpenFileDialog available in System.Windows.Forms in my web application to browse and get full path of selected access database file so that i can import data that file. I actually implemented this locally successfully but not sure whether it will work on live or not. Please suggest. What I have tried: I actually implemented this locally successfully using : public string getSelectedfilePath() { string str = string.Empty; System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Title = "Select database file"; openFileDialog.InitialDirectory = "C:\\"; openFileDialog.Filter = "Access Database files (*.mdb, *.accdb)|*.mdb; *.accdb|All files (*.*)|*.*"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { str = Convert.ToString(openFileDialog.FileName); } return str; } but not sure whether it will work on live or not. Please suggest.
推荐答案你不应该在Asp.Net中使用 OpenFileDialog ,而应该去 Asp:FileUpload 控制 file-upload-control / [ ^ ] FileUpload Control [ ^ ] You should not use OpenFileDialog in Asp.Net, instead you should go for Asp:FileUpload Control file-upload-control/[^] FileUpload Control[^]
更多推荐
我们可以在Web应用程序中使用system.windows.forms的openfiledialog吗?
发布评论