Guest User

Untitled

a guest
Feb 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. [HttpGet]
  2. [OutputCache(Duration = 60, VaryByParam = "none", Location =
  3. OutputCacheLocation.Client, NoStore = true)]
  4. public FileResult AppleUserDataReport()
  5. {
  6. using (ZipFile zip = new ZipFile())
  7. {
  8. zip.Password = Membership.GeneratePassword(12, 1);
  9. var sb = _service.GetAppleUsersByClientId(User.ClientId);
  10. var reportName = "AppleUserData_Downloaded_" + DateTime.UtcNow.ToString("yyyy_MM_dd");
  11.  
  12. var contentType = "text/xml";
  13. var bytes = Encoding.UTF32.GetBytes(sb.ToString());
  14.  
  15. var result = new FileContentResult(bytes, contentType);
  16. result.FileDownloadName = reportName + ".csv";
  17.  
  18. zip.AddFile(result.FileDownloadName, "file");
  19. zip.Save("C:\MyZipFile.zip");
  20.  
  21. return result;
  22. }
  23. }
Add Comment
Please, Sign In to add comment