title: Convert DICOM to PNG using dicom2.exe
body: <p>I am currently trying to convert DICOM files to PNG files using a command line program named <a href="http://www.barre.nom.fr/medical/dicom2/" rel="nofollow">dicom2</a>.</p>
  
  <p>Below is the code from a .NET toy application that I wrote to test its conversion functionality. It attempts to run dicom2 from within a C# console application:</p>
  
  <pre><code>public static void Main(string[] args)
  {
      StartDicom2();
      Console.ReadLine();
  }
  
  private static void StartDicom2()
  {
      string fileName = @"E:\Temp\Projects\FYP\SCE11-0353\Uploads\dicom2.exe";
      string commandLineArguments = @"-p *.dcm";
  
      ProcessStartInfo info = new ProcessStartInfo();
      info.CreateNoWindow = false;
      info.UseShellExecute = false;
      info.FileName = fileName;
      info.Arguments = commandLineArguments;
  
      try
      {
          Process dicom2 = Process.Start(info);
          dicom2.WaitForExit();
      }
      catch(Exception e)
      {
          Console.WriteLine(e.ToString());
      }
  }
  </code></pre>
  
  <p>Now for some reason dicom2 does not start execution at all.</p>
  
  <p>Upon debugging, it was discovered that a <code>System.InvalidOperationException</code> was thrown. Not sure whether it came from dicom2 or something else.</p>