2013-05-07 5 views
0

저는 다국어 사이트의 MVC 및 현지화를 둘러 보았습니다. 이렇게 나는 또한 현지화 한 다운로드가있다 (다른 언어에있는 지시). 나는 리소스가 파일을 포함 할 수 있다고 생각했다. 쉽게 말했지만 끝났지 만, 이제 내 질문은 : 리소스 파일에서 파일을 추출하여 사용자가 열거 나 저장할 수 있도록하는 방법은 무엇입니까?MVC 4 - 리소스에서 지역화 된 파일을 다운로드하는 방법은 무엇입니까?

ResourceManager.GetObject("filename in resource", what type will it be?) 또는 ResourceManager.GetStream("filename in resource", what type will it be?)을 사용하고 파일로 어떻게 반환합니까?

나는 this 게시물을보고 있었지만 이것이 필요한지 확실하지 않습니다.

답변

0

내가 해냈어. ResourceManager이 전혀 필요하지 않았습니다.

public FileResult Download(string filename) 
    { 
     byte[] fileBytes = null; 

     switch (filename) 
     { 
      case "Flyer Instructie.pdf": 
       fileBytes = Resources.Resources.Flyer_Instructie; 
       break; 
      case "Flyer Front.pdf": 
       fileBytes = Resources.Resources.Flyer_Front; 
       break; 
      case "Flyer Back.pdf": 
       fileBytes = Resources.Resources.Flyer_Back; 
       break; 
     } 

     return File(fileBytes, MediaTypeNames.Application.Octet, filename); 

    } 

그리고 내보기 : 내 컨트롤러에서

<%: Html.ActionLink(Resources.DownloadsInstructionText, "Download", "Home", new { filename = Resources.DownloadsInstructionLink }, null) %> 
관련 문제