我有一个报告,我想直接保存它而无需对话。
这是我的代码
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = @"C:temp";
saveFileDialog.RestoreDirectory = true;
saveFileDialog.Title = "Browse Text Files";
saveFileDialog.DefaultExt = "doc";
saveFileDialog.Filter = "Word Doc (*.doc)|*.doc|PDF (*.pdf)| *.pdf";
saveFileDialog.CheckFileExists = false;
saveFileDialog.CheckPathExists = true;
Warning[] warnings;
string[] streams;
string mimeType;
string encoding;
string extension;
byte[] bytes = reportTest.LocalReport.Render("Word", null, out mimeType, out encoding, out extension, out streams, out warnings);
//if (saveFileDialog.ShowDialog() == DialogResult.OK)
//{
saveFileDialog.FileName = "123.doc";
var filename = saveFileDialog.FileName;
System.IO.FileStream file = new FileStream(filename, FileMode.Create);
file.Write(bytes, 0, bytes.Length);
file.Close();
//}
有人可以帮助我如何将文件直接保存到c: temp 123.doc(在资源管理器中没有对话框)。
非常感谢!
您可以直接使用路径名和文件名
直接保存此保存filename="PATH" + "test.doc";
System.IO.FileStream file = new FileStream(filename, FileMode.Create);