I am trying to download a password encrypted zip file that gets created on button push using dotnetzip.
On button push, I hit my report controller and call this function
[HttpGet]
[OutputCache(Duration = 60, VaryByParam = "none", Location =
OutputCacheLocation.Client, NoStore = true)]
public FileResult AppleUserDataReport()
{
using (ZipFile zip = new ZipFile())
{
zip.Password = Membership.GeneratePassword(12, 1);
var sb = _service.GetAppleUsersByClientId(User.ClientId);
var reportName = "AppleUserData_Downloaded_" + DateTime.UtcNow.ToString("yyyy_MM_dd");
var contentType = "text/xml";
var bytes = Encoding.UTF32.GetBytes(sb.ToString());
var result = new FileContentResult(bytes, contentType);
result.FileDownloadName = reportName + ".csv";
zip.AddFile(result.FileDownloadName, "file");
zip.Save("C:\\MyZipFile.zip");
return result;
}
}
I keep getting the error
Access to the path 'C:\DotNetZip-gy22lp3l.tmp' is denied.
I have no idea how this .tmp file is getting created or why its giving me an access denied error.
I used the same code as found in other questions with this error but kept getting the same error, any help would be great.