我有一个数据网格视图,在其中一个单元格中我必须提供下载文件选项。我正在动态创建 xml 文件,当用户单击下载按钮时,他/她应该能够这样做.. . 我迷路了
private void DownloadFile(ScriptInfo scriptInfo)
{
XDocument doc =
new XDocument(
new XElement("scriptfilenames",
new XElement("SqlEye",
new XElement("scriptfilename", new XAttribute("fileName", scriptInfo.FileName),
new XElement("warnings",
scriptInfo.ErrorMessages[RuleAction.Error].Select(x => new XElement("warning", new XAttribute("value", x)))),
new XElement("remarks",
scriptInfo.ErrorMessages[RuleAction.warning].Select(x => new XElement("remark", new XAttribute("value", x))))
))));
string fileName = scriptInfo.FileName;
FileInfo fileInfo = new FileInfo(fileName);
string fileExtension = ".xml";
byte[] byteData = null;
//show save as dialog
using (SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
//Set Save dialog properties
saveFileDialog1.Filter = "Files (*" + fileExtension + ")|*" + fileExtension;
saveFileDialog1.Title = "Save File as";
saveFileDialog1.CheckPathExists = true;
saveFileDialog1.FileName = fileName;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
//what will be here????
}
}
}
需要帮助..
提前致谢