title: Detect if Adobe Acrobat Reader on .NET is running
body: <p>I'm using PDFSharp to create a PDF.  In their examples, they save a PDF and then then they start a process to choose your viewer to open it.  It looks like this:</p>
  
  <pre><code>document.Save(fileName);
  Process.Start(fileName);    
  </code></pre>
  
  <p>So in my testing, I realized that if Acrobat Reader is already open, I get an i/o exception because the process is already running.  So I tried following this post: 
  <a href="https://stackoverflow.com/questions/187915/detecting-a-process-is-already-running-in-windows-using-c-sharp-net">Detecting a Process is already running in windows using C# .net</a></p>
  
  <p>about detecting the process.  So I changed the above code to this:</p>
  
  <pre><code>        document.Save(fileName);
          if (System.Diagnostics.Process.GetProcessesByName("AcroRd32.exe").Length == 0)
          {
              Process.Start(fileName);    
          }
  </code></pre>
  
  <p>So I have two questions.<br>
  1) This doesn't work.  The Length is always 0 so I'm wondering if I am returning the wrong process or it can't find the process.  When I look in Task Manager, that AcroRd32.exe is the name of the process that is being run.</p>
  
  <p>2) Is there a better way to do this?  It seems like I'm hardcoding this process into the code and I wasn't sure if there was a better way to catch either other versions of Acrobat (like if there was a 64-bit version), or other PDF viewers in general.</p>
  
  <p>Sorry if this is noob question.  This .NET is pretty new to me.  Thanks.</p>