Zip and Unzip using Proces.StartInfo
-
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?
-
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?
Are you passing correct parameters?
Giorgi Dalakishvili #region signature my articles #endregion
-
Are you passing correct parameters?
Giorgi Dalakishvili #region signature my articles #endregion
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.) -
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.)You only need two Parameters: 1. ZipFileName including destination directory 2. The file(s) you wish to zip including source directory. Robert