我試圖將文件保存到用戶電腦,但我無法做到這一點。 此方法提供錯誤,因爲正試圖將文件保存在C的某處。我明白這並不合適。我想將文件保存在下載文件夾中或通過文件對話框提示用戶。ASP.net下載並保存用戶文件夾中的文件
void SaveReport(Telerik.Reporting.Report report, string fileName)
{
ReportProcessor reportProcessor = new ReportProcessor();
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = report;
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
}
如何將文件保存在用戶機器的下載文件夾中或提示filedialog以允許用戶選擇目的地?
filestream將寫入服務器上的文件而不是客戶端的機器上。嘗試將文檔字節寫入響應輸出流和內容處置http頭以響應。 –