回答
不指定环境,这里的WinForms代码片段:
static class Example
{
public static XmlTextWriter GetWriterForFolder(string fileName, Encoding encoding)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
if (dlg.ShowDialog() != DialogResult.OK)
return null;
XmlTextWriter writer = new XmlTextWriter(Path.Combine(dlg.SelectedPath, fileName), encoding);
writer.Formatting = Formatting.Indented;
return writer;
}
public static XmlTextWriter GetWriterForFile(Encoding encoding)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "XML Files (*.xml)|*.xml";
if (dlg.ShowDialog() != DialogResult.OK)
return null;
XmlTextWriter writer = new XmlTextWriter(dlg.FileName, encoding);
writer.Formatting = Formatting.Indented;
return writer;
}
}
的GetWriterForFolder
功能让用户选择,其中文件将被保存的文件夹,你必须提供一个文件名作为参数。就像这样:
string fileName = "EFIX.036003.CMF.FIX." + sDate + ".CMF003.xml";
XmlTextWriter writer = Example.GetWriterForFolder(fileName, Encoding.UTF8);
的GetWriterForFile
功能让用户选择一个文件夹,使用的文件名。像这样:
XmlTextWriter writer = Example.GetGetWriterForFile(Encoding.UTF8);
下面
感谢@ adriano为您的回复 你可以告诉我在web应用程序按钮单击我怎样才能显示保存对话框到用户 下面是我的代码按钮点击 xmlFileName =“EFIX.036003.CMF.FIX。”+ SDATE + “CMF003.xml”; \t \t \t \t \t \t \t \t \t \t XmlTextWriter的瓦特=新的XmlTextWriter(@ “d:\” + xmlFileName,Encoding.UTF8); \t \t \t w.Formatting = Formatting.Indented; \t \t \t \t \t \t \t \t \t w.WriteStartDocument(); \t \t \t w.WriteStartElement(“Document”); \t \t \t w.WriteAttributeString(“xmlns:xsi”,“http://www.w3.org/2001/XMLSchemainstance”); w.WriteEndElement(); \t \t \t w.WriteEndDocument(); \t \t \t \t \t \t \t w.Close(); – SeeSharp 2012-03-27 08:19:21
在Web应用程序中?用ASP.NET标记你的问题!它真的**不同! Plain ASP.NET? MVC?服务器应该提供一个URL来创建该文件,用户可以单击一个链接(或一个LinkButton)来下载该文件并将其保存在本地。 – 2012-03-27 08:58:22
大家好,我已经使用httpresponse来解决我的问题。创建XML后我已经使用httpresponse与内容类型文本/ xml 感谢所有 – SeeSharp 2012-03-29 09:22:13
- 1. 使用保存文件对话框保存xml文件
- 2. 保存文件保存对话框
- 3. 如何使用保存文件保存文件对话框
- 4. 保存文件不使用保存文件对话框
- 5. 如何使用保存对话框创建和保存ics文件?
- 6. 使用Javascript保存文件对话框
- 7. 保存文件用的JFileChooser保存对话框
- 8. 用saveas对话框保存文件?
- 9. 文件的对话框创建/保存在球拍
- 10. 如何保存使用PHPExcel创建的Excel文件,而不使用对话框?
- 11. 保存对话框
- 12. 保存对话框
- 13. 保存没有对话框的文件
- 14. 保存文件对话框,当在java中使用extjs创建excel文件
- 15. 如何从C#中的保存文件对话框保存?
- 16. 提示用户使用“另存为”对话框保存文件?
- 17. 如何在html中创建保存文件对话框
- 18. 如何从Spring控制器创建文件保存对话框?
- 19. iTextSharp:创建PDF文件时显示“打开/保存”对话框
- 20. 如何在C#中使用保存对话框保存ASCII文本文件?
- 21. 挂钩保存文件对话框
- 22. android java - 保存文件对话框GUI
- 23. C#保存文件对话框错误
- 24. 在Jquery中保存文件对话框
- 25. 打开/保存文件对话框
- 26. 在griffon中保存文件对话框
- 27. 在MVC中保存文件对话框
- 28. 保存文件对话框确认
- 29. 文件打开/保存对话框
- 30. PHP“保存对话框”文件从
是代码 xmlFileName = “EFIX.036003.CMF.FIX。” + SDATE + “CMF003.xml。”; \t \t \t \t \t \t \t \t \t \t XmlTextWriter的瓦特=新的XmlTextWriter(@ “d:\” + xmlFileName,Encoding.UTF8); \t \t \t w.Formatting = Formatting.Indented; – SeeSharp 2012-03-27 07:48:39