Displaying Save File Dialog in Asp.net web page(在 Asp.net 网页中显示保存文件对话框)
问题描述
我有一个将文件写入本地磁盘的 ASP.net 页面.
I have a ASP.net page which writes a file to the local disk.
我想向用户显示一个保存文件对话框并允许他设置文件夹的路径.
I want to present the user a Save File dialog box and allow him to set the path to the folder.
我知道可以使用下面的代码;
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();
但它修复了文件路径.
我需要捕获用户选择的文件路径.这在 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.
这篇关于在 Asp.net 网页中显示保存文件对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Asp.net 网页中显示保存文件对话框


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01