将文件保存到特定路径 [英] saving a file to a specific path
本文介绍了将文件保存到特定路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = "*.html"; dialog.Filter = "WORD Document (*.html)|*.html"; if (dialog.ShowDialog() == true) { RadDocument document = CreateDocument(rgvReportData); document.LayoutMode = DocumentLayoutMode.Paged; document.Measure(RadDocument.MAX_DOCUMENT_SIZE); document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize)); document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(2, 2, 2, 2); document.SectionDefaultPageOrientation = PageOrientation.Landscape; HtmlFormatProvider provider = new HtmlFormatProvider(); using (Stream output = dialog.OpenFile()) { provider.Export(document, output); } }
解决方案
在最后一句中,"using
":
using (Stream output = File.OpenWrite(@"C:\myreport.html")) // or whatever path. provider.Export(document, output); // Remember "using System.IO;"
顺便说一句,只需删除与文件保存对话框相关的所有代码即可.
hi! i have the code for saving a gridview as an html file using a savefiledialog. i want to save it to a specific path (without using the savefiledialog)... how can i do that?
here''s my code:
SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = "*.html"; dialog.Filter = "WORD Document (*.html)|*.html"; if (dialog.ShowDialog() == true) { RadDocument document = CreateDocument(rgvReportData); document.LayoutMode = DocumentLayoutMode.Paged; document.Measure(RadDocument.MAX_DOCUMENT_SIZE); document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize)); document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(2, 2, 2, 2); document.SectionDefaultPageOrientation = PageOrientation.Landscape; HtmlFormatProvider provider = new HtmlFormatProvider(); using (Stream output = dialog.OpenFile()) { provider.Export(document, output); } }
how can i sve it without using a savefiledialog?
解决方案
In the last sentence, the "using
":
using (Stream output = File.OpenWrite(@"C:\myreport.html")) // or whatever path. provider.Export(document, output); // Remember "using System.IO;"
By the way, just remove any code related to the file save dialog.
这篇关于将文件保存到特定路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文