Share via


How to Check a file is .ZIP or not ?

Question

Friday, March 2, 2012 6:19 AM

Hi everybody,

I have requirement that the user have to select a .zip file and not any other file.

So i have to make a condition to check the file is .zip or not so please help me.

thanks

CRMAbhi

All replies (4)

Friday, March 2, 2012 6:27 AM ✅Answered

if  (Path.GetExtension(string path).Equals(".zip"))

{
blabla

}
else
{

bloblo

}

Peter Koueik


Friday, March 2, 2012 6:42 AM ✅Answered

You can use DotNetZip library to validate a zip file content.

bool ZipFile.CheckZip(string zipFileName);

http://dotnetzip.codeplex.com/discussions/76182

Resolving n Evolving in C# (http://jeanpaulva.com)


Friday, March 2, 2012 6:43 AM

Thanks Peter you rock.

CRMAbhi


Friday, March 2, 2012 6:45 AM

welcome!

Peter Koueik