C# Shell32 - Error: The system cannot find the file specified.

Discussion in 'General Computer Support' started by cmedine, Jan 31, 2011.

  1. cmedine

    cmedine

    Joined:
    Jan 31, 2011
    Messages:
    1
    Likes Received:
    0
    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.

    Here is my code - Any help is appreciated:

    Code:
    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); }                                
    
                    }
                }
     
    cmedine, Jan 31, 2011
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.