.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to unzip a file using Shell32?

Posted By:Jean Paul       Posted Date: February 04, 2011    Points: 15    Category: File Operation    URL: http://www.dotnetspark.com  

Add reference to Shell32.dll from c:\windows\system32 folder
 

DirectoryInfo di = new DirectoryInfo(@"C:\Temp\");

            foreach (FileInfo fi in di.GetFiles("*.zip"))
            {
                String file = fi.ToString();
                var destinationPath = @"C:\Temp\AppName\";
                if (!Directory.Exists(destinationPath))
                    Directory.CreateDirectory(destinationPath);

                Shell sh = new Shell();
                Folder destFlder = sh.NameSpace(destinationPath);
                Folder srcFlder = sh.NameSpace(fi.FullName);
                foreach (FolderItem F in srcFlder.Items())
                {
                    destFlder.CopyHere(F, null);
                }
            }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend