title: How to export a registry in c#
body: <p>I have been trying to export and save registry files to an arbitrary location, the code is running. However, on specifying the path and saving, the function does not work and no registry is exported. There is no error shown either.</p>
  
  <pre><code>private static void Export(string exportPath, string registryPath)
  { 
      string path = "\""+ exportPath + "\"";
      string key = "\""+ registryPath + "\"";
      // string arguments = "/e" + path + " " + key + "";
      Process proc = new Process();
  
      try
      {
          proc.StartInfo.FileName = "regedit.exe";
          proc.StartInfo.UseShellExecute = false;
          //proc.StartInfo.Arguments = string.Format("/e", path, key);
  
          proc = Process.Start("regedit.exe", "/e" + path + " "+ key + "");
          proc.WaitForExit();
      }
      catch (Exception)
      {
          proc.Dispose();
      }
  }
  </code></pre>