pdf 파일을 다운로드하는 데 문제가 있습니다. 다른 파일은 다운로드됩니다. 코드 : 유C#에서 PDF 파일을 다운로드하는 코드
답변
확인이 방법을 알고있는 경우
WebClient client = new WebClient();
client.DownloadFile(remoteFilename, localFilename);
pls는 저를 도와, 희망
public static void DownloadFile(HttpResponse response,string fileRelativePath)
{
try
{
string contentType = "";
//Get the physical path to the file.
string FilePath = HttpContext.Current.Server.MapPath(fileRelativePath);
string fileExt = Path.GetExtension(fileRelativePath).Split('.')[1].ToLower();
if (fileExt == "pdf")
{
//Set the appropriate ContentType.
contentType = "Application/pdf";
}
//Set the appropriate ContentType.
response.ContentType = contentType;
response.AppendHeader("content-disposition", "attachment; filename=" + (new FileInfo(fileRelativePath)).Name);
//Write the file directly to the HTTP content output stream.
response.WriteFile(FilePath);
response.End();
}
catch
{
//To Do
}
}
contentType = "Application/pdf"를 설정해야합니다. 다운로드 한 파일이 올바른지 확인하십시오 PDF 파일 –
감사합니다 Mahmoud 시도했지만 다음 오류가 발생합니다 : 형식 또는 네임 스페이스 이름 'HttpResponse'찾을 수 없습니다 (사용 지시문 또는 어셈블리 참조가 누락되었습니다.) –
있습니다. 당신은 웹 응용 프로그램이나 데스크탑 응용 프로그램에서 일하고 있습니까 ?? –
@Syed Mudhasir하는 데 도움이 : 그것의 단지 라인 :
client.DownloadFileAsync(new Uri(remoteFilename, UriKind.Absolute), localFilename);
을
PDF 파일을 다운로드합니다. :)
다음 코드 샘플을 다운로드하여 .pdf 파일을 다운로드하십시오.
Response.ContentType = "Application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=Test_PDF.pdf");
Response.TransmitFile(Server.MapPath("~/Files/Test_PDF.pdf"));
Response.End();
이 나를 위해 일한 :
string strURL = @"http://192.168.1.xxx/" + sDocumento;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + sDocumento + "\"");
byte[] data = req.DownloadData(strURL);
response.BinaryWrite(data);
response.End();
- 1. Seam 내부에서 파일을 다운로드하는 방법 PDF
- 2. UIWebView에서 doc 또는 pdf 파일을 다운로드하는 방법
- 3. C에서 큰 파일을 프로그래밍 방식으로 다운로드하는 방법
- 4. Objective-C에서 PDF 생성
- 5. C에서 변환을 수행하는 Pdf #
- 6. C에서 HTML 소스를 다운로드하는 방법
- 7. docx, pdf, image, pptx 또는 인터넷에서 파일을 다운로드하는 방법
- 8. mysql 데이터베이스에서 pdf 파일을 보는 PHP 코드
- 9. C에서 PDF 읽기 #
- 10. 다른 서버에서 파일을 다운로드하는 서버에서 파일을 다운로드하는 방법은 무엇입니까?
- 11. Java에서 파일을 다운로드하는 방법?
- 12. 파일을 PHP로 다운로드하는 방법
- 13. 루프에서 여러 파일을 다운로드하는 PHP 헤더
- 14. Objective C에서 PDF 테이블 만들기
- 15. 파일을 다운로드하는 동안 PrintWriter 사용
- 16. iPhone에 로컬로 epub 파일을 다운로드하는 방법은 무엇입니까?
- 17. 파일을 다운로드하는 동안 웹 서버에서 파일을 삭제하십시오.
- 18. asp.net - 서버에서 파일을 다운로드하는 방법
- 19. iphone에 zip 파일을 다운로드하는 방법?
- 20. ftp에서 파일을 다운로드하는 방법은 무엇입니까?
- 21. php - 강제로 파일을 다운로드하는 방법?
- 22. lighttpd에서 PHP 파일을 다운로드하는 방법
- 23. 여러 스레드로 파일을 다운로드하는 방법
- 24. URL에서 mp3 파일을 다운로드하는 방법
- 25. iOS에서 대용량 파일을 다운로드하는 방법은 무엇입니까?
- 26. 서버에서 로컬 호스트로 파일을 다운로드하는 방법
- 27. PDF 뷰어의 코드 누설
- 28. 안드로이드에있는 PHP 서버에서 파일 (pdf, png 등)을 다운로드하는 방법
- 29. C에서 malloc 코드
- 30. C에서 유니 코드 문자열 #
문제가 무엇입니까? –
내 문제는 위에서 언급 한 코드 대신 pdf 파일을 다운로드하여 pdf 문서로 저장 한 후입니다. wen 열려고하면 문서 복구 오류가 표시됩니다. –
내가 ... 링크 '당신을 도울 것이다 아래이 희망 http://stackoverflow.com/questions/10829168/can-we-use-response-flush-instead-of-response-end/17038408 # 17038408 – Viishnuu