Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error while Extracting Files in zip folder

Error while Extracting Files in zip folder

Scheduled Pinned Locked Moved C#
linuxhelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arun_pk
    wrote on last edited by
    #1

    i am using below code to extract the files inside the zip folder. getting an error while using copyHere method .. after deleteing the folder i m trying to create a new one . and then copying from the zip file but still it gives an error "File exist" Please provide a solution thanks in advance

    if (Directory.Exists(unzipFilePath))
    {
    Directory.Delete(unzipFilePath, true);
    Directory.CreateDirectory(unzipFilePath);
    }
    else
    {
    Directory.CreateDirectory(unzipFilePath);
    }
    Shell objShell = new Shell();
    Folder shellZipFile = objShell.NameSpace(zipFilePath);
    Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
    foreach (FolderItem zipFileitem in shellZipFile.Items())
    {
    shellUnZipFile.CopyHere(zipFileitem, 0);//File exist error is thrown from shell
    }

    This error is happening in a particular system

    OriginalGriffO 1 Reply Last reply
    0
    • A arun_pk

      i am using below code to extract the files inside the zip folder. getting an error while using copyHere method .. after deleteing the folder i m trying to create a new one . and then copying from the zip file but still it gives an error "File exist" Please provide a solution thanks in advance

      if (Directory.Exists(unzipFilePath))
      {
      Directory.Delete(unzipFilePath, true);
      Directory.CreateDirectory(unzipFilePath);
      }
      else
      {
      Directory.CreateDirectory(unzipFilePath);
      }
      Shell objShell = new Shell();
      Folder shellZipFile = objShell.NameSpace(zipFilePath);
      Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
      foreach (FolderItem zipFileitem in shellZipFile.Items())
      {
      shellUnZipFile.CopyHere(zipFileitem, 0);//File exist error is thrown from shell
      }

      This error is happening in a particular system

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that true will delete files and subdirectories. However, when you look at the example on the same page it says:

              'This operation will not be allowed because there are subdirectories.
      

      for the VB example, and

              // This will succeed because subdirectories are being deleted
      

      for the C#. I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      A 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that true will delete files and subdirectories. However, when you look at the example on the same page it says:

                'This operation will not be allowed because there are subdirectories.
        

        for the VB example, and

                // This will succeed because subdirectories are being deleted
        

        for the C#. I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        A Offline
        A Offline
        arun_pk
        wrote on last edited by
        #3

        Thanks for the reply phiscally i checked the folder it was wmpty and then i inserted below code in copy..

        if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
        {
        File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
        }
        shellUnZipFile.CopyHere(zipFileitem, 0); // still it throwd error

        OriginalGriffO 1 Reply Last reply
        0
        • A arun_pk

          Thanks for the reply phiscally i checked the folder it was wmpty and then i inserted below code in copy..

          if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
          {
          File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
          }
          shellUnZipFile.CopyHere(zipFileitem, 0); // still it throwd error

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Don't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          A 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Don't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

            A Offline
            A Offline
            arun_pk
            wrote on last edited by
            #5

            I had checked through code, explorer by making files visible and all those stuff.. :( and one more thing in this specific computer.i tried something manually.. like i right clicked the zip file and selected explore. i got an option to copy the file But when i paste it paste is not happening.

            OriginalGriffO 1 Reply Last reply
            0
            • A arun_pk

              I had checked through code, explorer by making files visible and all those stuff.. :( and one more thing in this specific computer.i tried something manually.. like i right clicked the zip file and selected explore. i got an option to copy the file But when i paste it paste is not happening.

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Have you checked the folder permissions?

              Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              A 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Have you checked the folder permissions?

                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                A Offline
                A Offline
                arun_pk
                wrote on last edited by
                #7

                Yes i checkd.. normal settings

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups