이것은 내 코드이며 docx 파일을 다운로드 할 때까지 노력하고 있습니다. 그러나 성공은 없습니다. 내가 뒤처질 수있는 곳에서는 약간의 힌트가 필요합니다.C#을 사용하여 docx 파일을 다운로드 할 수 없습니다.
if (File.Exists(sTempPath + sCreateFileName))
{
FileInfo file =new FileInfo(sTempPath + sCreateFileName);
Response.ClearContent();
// LINE1: Add the file name and attachment, which will force the open/cancel/save dialog to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", file.Length.ToString());
// Set the ContentType
Response.ContentType = ReturnExtension(file.Extension.ToLower());
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(sTempPath + sCreateFileName);
// End the response
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
및 반환 콘텐츠 형식은 DOCX 파일, 콘텐츠 유형을 제공합니다
"application/ms-word"
곳 sTempPath + sCreateFileName 파일의 전체 경로 인 경우. 이 작동하지 않는
application/vnd.openxmlformats-officedocument.wordprocessingml.document
:
업데이트 : 나는 콘텐츠 형식을 시도했다.
어떤 오류가 있습니까? –
콘텐츠 형식을'application/vnd.openxmlformats-officedocument.wordprocessingml.document'로 시도하십시오 – Damith
오류는 없지만 파일이 다운로드되지 않습니다. –