保存/打开/取消对话框 [英] Save/Open/Cancel dialog box
问题描述
有人可以告诉我如何通过保存"对话框提示 将XML文件从网站网址保存到本地系统 .
我编写了以下代码,而不是将整个内容写在浏览器窗口本身上,而不是提示对话框.请告诉我我在哪里做错了.
Hi,
Can someone please tell me how to save an xml file from a site Url to local system by prompting through Save Dialog box.
I have written the following code rather writing the whole content on browser window itself rather than prompting through dialog box. Please tell me where I doing wrong.
string Filename = "http://localhost/SiteName/FileName.xml";
XmlDocument doc = new XmlDocument();
doc.Load(Filename);
string strXML = GetXMLString(doc);//Converts XMLDocument to string
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.ContentType = "application/xml"; //or text/xml
Response.AddHeader("content-disposition", String.Format("attachment;filename=" + Filename));
Response.WriteFile(strXML);
Response.Flush();
Response.Close();
Response.End();
谢谢.
推荐答案
查看以下内容: http://msdn.microsoft.com/zh-CN/library/8bh11f1k.aspx [ ^ ]
这是WinForms打开对话框的基本代码(WPF会稍有不同):
Look at the following: http://msdn.microsoft.com/en-us/library/8bh11f1k.aspx[^]
Here is the basic code for an open dialog for WinForms (WPF would be slightly different):
var save = new SaveFileDialog();
var open = new OpenFileDialog();
var result = open.ShowDialog();
if (result == DialogResult.OK)
MessageBox.Show("Filename selected to open is " + open.FileName);
请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.openfiledialog.aspx [ ^ ],以获取有关OpenFileDialog
和 ^ ]用于SaveDialog
See http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx[^] for more information on OpenFileDialog
, and http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx[^] for SaveDialog
这篇关于保存/打开/取消对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!