我们可以在Web应用程序中使用system.windows.forms的openfiledialog吗? [英] Can we use openfiledialog of system.windows.forms in web application?

查看:120
本文介绍了我们可以在Web应用程序中使用system.windows.forms的openfiledialog吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在我的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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆