Carrie Medine

Carrie Medine

  • NA
  • 3
  • 18.1k

C# unzipping using Shell32 throws Error: The system cannot find the file specified. - HELP

Jan 31 2011 3:23 PM

Hello,

I am using Shell32 to unzip files, but am getting the famous vague error: 

      The system cannot find the file specified. (Exception from HRESULT: 0x80070002).

The error is thrown at the srcFlder declaration.  I did check and ensure that the file is there so error must be something else.

Here is my code - Any help is appreciated:

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

            foreach (FileInfo fi in di.GetFiles("*.zip"))
            {
                foreach (DirectoryInfo dir in destinationDir)
                {
                    String file = fi.ToString();
                    var destinationPath = @"C:\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); }

                }
            }

Answers (1)