create directory based on zip files itself


dear all,

please tell me how create directory based on zip file.

example:

i have 2 zip files. abc.zip , cde.zip.

each of zip files, contains same  files.

abc.zip --contains--> 1.text,2.dat,3.txt

cde.zip --contains--> 1.text,2.dat,3.txt

those zip files @ c:\\zipfolder , have c:\\unzipfolder have prepare accept unzip folder, final result want :

from:

c:\\zipfolder\abc.zip,cde.zip

to be: 

 c:\\unzipfolder\abc\1.text,2.dat,3.txt

and

c:\\unzipfolder\cde\1.text,2.dat,3.txt

thank help.

best  regards,

bambang

hi bambang

you can use zipfile class add reference  system.io.compression.filesystem then use following code snippet:

using system; using system.io.compression;  namespace consoleapplication {     class program     {         static void main(string[] args)         {              string zipfile = @"c:\zipfolder\abc.zip";              //this statement target directory based on input zip file name without extension .zip             string target = @"c:\unzipfolder\" + system.io.path.getfilenamewithoutextension(zipfile);              //extract content target folder (zipfile create destination folder if not exist)             zipfile.extracttodirectory(zipfile, target);              console.readkey();         }       } }

don't forget add a reference to system.io.compression.filesystem library 




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user