1
public void ZipExtract(string zipfilename, string outputDirectory)
{       
    using (ZipFile zip = ZipFile.Read(zipfilename))//file not found exception
    {
        Directory.CreateDirectory(outputDirectory);
        zip.ExtractSelectedEntries("name=*.jpg,*.jpeg,*.png,*.gif,*.bmp", " ", 
            outputDirectory, ExtractExistingFileAction.OverwriteSilently);
    }
}

[HttpPost]
public ContentResult Uploadify(HttpPostedFileBase filedata)
{
    var path = Server.MapPath(@"~/Files");
    var filePath = Path.Combine(path, filedata.FileName);
    if (filedata.FileName.EndsWith(".zip"))
    {
        ZipExtract(filedata.FileName,path);
    }
    filedata.SaveAs(filePath);
    // CreateThumbnail(filePath);
    _db.Photos.Add(new Photo
        {
            Filename = filedata.FileName
        });

    _db.SaveChanges();
    return new ContentResult{Content = "1"};  
}

I try to extract the uploaded zip archive and save extracted files in a folder but "file not found" exception happens all the time. What's the mistake?

Rob
  • 45,296
  • 24
  • 122
  • 150
federer_15
  • 21
  • 1
  • 3
  • This is the same quesiton you asked previously http://stackoverflow.com/questions/5014659 , and the FileNotFound exception is what I suggested you would see, in my answer to that previous question. http://stackoverflow.com/questions/5014659/problem-with-extracting-files-with-dotnetzip-it-doesnt-extract-files-whats-th/5019364#5019364 – Cheeso Feb 23 '11 at 00:41

1 Answers1

0

Have you tried setting a break point here, and see what value filedata.FileName has? (And see if it actually exists on the server.)

if (filedata.FileName.EndsWith(".zip"))
      {
        ZipExtract(filedata.FileName,path);
     } 
Rauland
  • 2,944
  • 5
  • 34
  • 44