파일을 브라우저로 스트리밍하는 동안 오류가 발생하지만 두 번째에서 네 번까지입니다. 처음에는 잘 작동합니다. 여기 두 번째로 파일을 스트리밍하는 동안 오류가 발생했습니다.
C:\Users\gfinzer\AppData\Local\Temp\BTnADAkZ.pdf. could not be saved because the source file could not be read
코드입니다 다음 CopyStream 여기
protected void Page_Load(object sender, EventArgs e)
{
//Get the parameters
string reportName = Utils.ParseStringRequest(Request, "reportName") ?? string.Empty;
string reportGuid = Session["reportGuid"].ToString();
string path = Path.Combine(ReportPath(), Utils.GetSessionReportName(reportName, reportGuid));
using (var fileStream = File.Open(path, FileMode.Open))
{
Response.ClearHeaders();
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + reportName + "\"");
Response.AddHeader("Content-Length", fileStream.Length.ToString(CultureInfo.InvariantCulture));
StreamHelper.CopyStream(fileStream, Response.OutputStream);
Response.Flush();
}
}
입니다 :
public static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[32768];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
정확히 "두 번째 시간"입니까? 다시 게시 후? –
'StreamHelper.CopyStream'은 어떻게 작동합니까? 코드를 게시 할 수 있습니까? – Xharze
보고서 생성입니다. 이것은 보고서를 만드는 두 번째 시간입니다. 나는 CopyStream을 추가했다. –