title: 7z command line to compress folders
body: <p>I am trying to zip/7z folders using the command line of 7zG.exe. The code I have works for files but not folders. Could someone please show me the correct way using 7z command line to compress folders? Here is the sample code that works for files only. Whenever I try running this code 7zip shows a messagebox saying "Invalid Parameter"</p>
  
  <pre><code>string sourceName = "Folder\Folder1";
  string targetName = "Example.gz";
  
  // 1
  // Initialize process information.
  //
  ProcessStartInfo p = new ProcessStartInfo();
  p.FileName = "7zG.exe";
  
  // 2
  // Use 7-zip
  // specify a=archive and -tgzip=gzip
  // and then target file in quotes followed by source file in quotes
  //
  p.Arguments = "a -tgzip \"" + targetName + "\" \"" + sourceName + "\" -mx=9";
  p.WindowStyle = ProcessWindowStyle.Hidden;
  
  // 3.
  // Start process and wait for it to exit
  //
  Process x = Process.Start(p);
  x.WaitForExit();
  </code></pre>