显示保存文件对话框中的Asp.net网页

问题描述:

我有一个文件写入到本地磁盘一个ASP.net页面。

I have a ASP.net page which writes a file to the local disk.

我要present用户保存文件对话框,允许他设置文件夹的路径。

I want to present the user a Save File dialog box and allow him to set the path to the folder.

我知道code下面一样可以使用;

I know code like below can be used;

Response.Clear();
Response.ContentType = "text/csv";
Response.AddHeader( "Content-Disposition", "attachment;filename=\"report.csv\"" );
// write your CSV data to Response.OutputStream here
Response.End();

但它修复文件路径。

But it fixes filepath.

我需要用户选择捕获的文件路径。
这有可能在ASP.net?

I need to capture the filepath that the user selects. Is that possible in ASP.net?

感谢。

它并不像从网页工作,你必须开始下载的 suggestiong 的目标文件名,那么用户就可以覆盖你的建议的文件名,然后选择自己喜欢的任何文件夹或文件名,你的内容将保存在该位置。

it does not work like that from a web page, you have to initiate the download suggestiong a target file name then the user can override your suggested file name and select any folder or filename he likes and your content will be saved in that location.

不管你做什么用的本地路径,只有有意义的客户端机器上ASP.NET应用程序的服务器端。

you do nothing with a local path which only makes sense on the client machine on the server side of ASP.NET application.