private void ZipExtract(string zipfilename)
{
var path = Server.MapPath(@"~/Files");
ZipFile zip = ZipFile.Read(zipfilename);
zip.ExtractSelectedEntries("name=*.jpg,*.jpeg,*.png,*.gif,*.bmp", " ", path,ExtractExistingFileAction.OverwriteSilently);
}
[HttpPost]
public ContentResult Uploadify(HttpPostedFileBase filedata)
{
var path = Server.MapPath(@"~/Files");
var filePath = Path.Combine(path, filedata.FileName);
if (filedata.FileName.Contains(".zip"))
{
ZipExtract(filedata.FileName);
}
filedata.SaveAs(filePath);
}
Asked
Active
Viewed 923 times
0

Cheeso
- 189,189
- 101
- 473
- 713

federer_15
- 21
- 1
- 3
-
Try debugging and see whether `"name=*.jpg,*.jpeg,*.png,*.gif,*.bmp"` is a valid format or not. try using only one extension `*.jpg` that works – Karthik Chintala Dec 13 '12 at 13:21
1 Answers
0
what's the error you see? Exception? Other condition? You need to add some additional context to your question. But there are a couple things that stick out even without a better description.
employ a using() clause with the ZipFile class; it is IDisposable.
It looks like you try to extract the zip file before you call .SaveAs(). If I read your code correctly, that means the ZipFile.Read() is trying to read a file that has not yet been created. If that is the case it will throw a
FileNotFoundException
. I may be wrong about this; more text from you would help clarify.

Cheeso
- 189,189
- 101
- 473
- 713
-
I want my application to upload zip file, extract it and save extracted file in a folder("Files" for example) – federer_15 Feb 18 '11 at 13:36
-
I mean I don't have to create zip file, I must accept zip file as a parameter – federer_15 Feb 18 '11 at 14:52
-
Right, well - if I am reading your code correctly, you are trying to read from a file location before saving data to that file location. If you want to read from the filesystem, You should save the uploaded file before trying to do so. – Cheeso Feb 23 '11 at 00:39