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. Zip and Unzip using Proces.StartInfo

Zip and Unzip using Proces.StartInfo

Scheduled Pinned Locked Moved C#
csharphelpquestion
4 Posts 3 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.
  • J Offline
    J Offline
    JustRonald
    wrote on last edited by
    #1

    Hi, I need to unzip and zip files using WinRAR in my C# application. The unzip part is complete and 100% working but I'm not getting the zip function to work. Below you see my zip function:

    Process Unzip = new Process();
    Unzip.StartInfo.Arguments = "x -p" + txtPassword.Text + " \"" + ZipFile + "\" \"" + outputDirectory + "\\temp\"";
    Unzip.StartInfo.CreateNoWindow = false;
    Unzip.StartInfo.FileName = rarName;
    Unzip.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    Unzip.StartInfo.WorkingDirectory = rarDirectory;
    Unzip.Start();
    Unzip.WaitForExit();
    Unzip.Close();
    Unzip.Dispose();

    To zip the files that are in the outputDirectory (C:\outputDirectory\temp) I have the same as the zip function. Only the Atguments are different:

    Zip.StartInfo.Arguments = "a \"" + Path.GetFileName(zipName) + "\" \"" + ZipFile + "\" \"" + newDir + "\"";

    For some reason he is unzipping the files but is not creating a zip file. Can anyone help me with this?

    G 1 Reply Last reply
    0
    • J JustRonald

      Hi, I need to unzip and zip files using WinRAR in my C# application. The unzip part is complete and 100% working but I'm not getting the zip function to work. Below you see my zip function:

      Process Unzip = new Process();
      Unzip.StartInfo.Arguments = "x -p" + txtPassword.Text + " \"" + ZipFile + "\" \"" + outputDirectory + "\\temp\"";
      Unzip.StartInfo.CreateNoWindow = false;
      Unzip.StartInfo.FileName = rarName;
      Unzip.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      Unzip.StartInfo.WorkingDirectory = rarDirectory;
      Unzip.Start();
      Unzip.WaitForExit();
      Unzip.Close();
      Unzip.Dispose();

      To zip the files that are in the outputDirectory (C:\outputDirectory\temp) I have the same as the zip function. Only the Atguments are different:

      Zip.StartInfo.Arguments = "a \"" + Path.GetFileName(zipName) + "\" \"" + ZipFile + "\" \"" + newDir + "\"";

      For some reason he is unzipping the files but is not creating a zip file. Can anyone help me with this?

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Are you passing correct parameters?

      Giorgi Dalakishvili #region signature my articles #endregion

      J 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        Are you passing correct parameters?

        Giorgi Dalakishvili #region signature my articles #endregion

        J Offline
        J Offline
        JustRonald
        wrote on last edited by
        #3

        Well something is wrong with the parameters I give....but I don't know what. When I start debugging this line: Zip.StartInfo.Arguments = "a \"" + Path.GetFileName(zipName) + "\" \"" + ZipFile + "\" \"" + newDir + "\""; looks like: a "DC2tempDir.zip" "C:\OutputDirectory\temp\P1010827.JPG" "C:\OutputDirectory\01\01.A\" What I'm trying to do is creating a new zip file in "C:\OutputDirectory\01\01.A\" with the name "DC2tempDir.zip". The content of the zip file must be the .jpg file in the temp dir. Is there something that I'm doing wrong here? (I'm using WinRAR btw.)

        R 1 Reply Last reply
        0
        • J JustRonald

          Well something is wrong with the parameters I give....but I don't know what. When I start debugging this line: Zip.StartInfo.Arguments = "a \"" + Path.GetFileName(zipName) + "\" \"" + ZipFile + "\" \"" + newDir + "\""; looks like: a "DC2tempDir.zip" "C:\OutputDirectory\temp\P1010827.JPG" "C:\OutputDirectory\01\01.A\" What I'm trying to do is creating a new zip file in "C:\OutputDirectory\01\01.A\" with the name "DC2tempDir.zip". The content of the zip file must be the .jpg file in the temp dir. Is there something that I'm doing wrong here? (I'm using WinRAR btw.)

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          You only need two Parameters: 1. ZipFileName including destination directory 2. The file(s) you wish to zip including source directory. Robert

          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