简体   繁体   English

另存为对话框C#

[英]Save As Dialog Box C#

I have one export method which gives me one .txt file. 我有一种导出方法,可以给我一个.txt文件。 That file is getting saved on Downloads on my machine. 该文件已保存在我计算机上的“ 下载 ”中。

I want one save as pop up which ask user where they want to save that downloaded file, as well as they can name the file. 我想要一个另存为弹出窗口,询问用户他们要将下载的文件保存在哪里,以及他们可以命名该文件。

I assume you mean the situation where the browser is automatically saving the file and not asking where to save it? 我假设您的意思是浏览器自动保存文件而不询问保存位置的情况?

This is controlled by the Content-Disposition header (19.5.1). 这由Content-Disposition标头 (19.5.1)控制。 If you add a header like 如果添加标题

Content-Disposition: attachment; filename="file.txt"

then the browser understands that it is an attachment and should ask what to do with it. 那么浏览器就会知道它是附件,应询问如何处理它。

However, the browser may choose to do something else with it. 但是,浏览器可能会选择对其进行其他处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM