2017-04-09 3 views
0

나는 다음과 같은 코드를 사용하여 System.Web.HttpContext.Current.Response을 사용하여 파일을 다운로드하려고 :ASP.net 다운로드 파일 사용 HttpContext.Current.Response fileName에

HttpResponse objResponse = System.Web.HttpContext.Current.Response; 

내가 파일 이름을 인코딩하고를 사용 :

FileName = Uri.EscapeDataString(FileName); 

파일 이름에 쉼표 또는 점이있는 경우를 제외하고 파일이 올바르게 다운로드됩니다.

그런 경우 파일을 다운로드하는 동안 탐색기에서 쉼표 다시 디코딩 할 수 없습니다. 예를 들어

:

Original file name: Testing, File 
Encoded name: Testing%2C%20file 
Downloaded file name: Testing%2C file 

코드에 어떤 방법이 있나요/쉼표와 점을 유지하기 위해 파일 이름을 인코딩?

+0

를 파일 이름을 인코딩하는 이유는 무엇입니까? 그것은 URI가 아닙니다. –

답변

0

예를 들어, 당신은 사용할 수 있습니다

public ActionResult DownloadFileXML(string filePath) 
{ 
string fileName = Path.GetFileName(filePath); 
return File(filePath, "application/xml", fileName); 
} 
관련 문제