title: Access Denied trying to purge printqueue in C#
body: <p>I'm trying to make a method in C# that empties all items in a print queue. Below is my code:</p>
  
  <pre><code>LocalPrintServer localPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministratePrinter); 
  PrintQueue printQueue = localPrintServer.GetPrintQueue(printerName);
  
  if (printQueue.NumberOfJobs &gt; 0)
  {
      printQueue.Purge();
  }
  </code></pre>
  
  <p>When this code runs, on the localPrintServer constructor, the app throws this error: 
  "An exception occurred while creating the PrintServer object. Win32 error: Access is denied."</p>
  
  <p>That constructor has a few overloads (including sending no parameters). Trying any of those, I get past that line, but when I get to the printQueue.Purge() call, I get the same access denied message as listed above. </p>
  
  <p>Looking for suggestions of how / what I can do to get around this. I can manually delete the print jobs from my computer. I'm not sure if the app runs with the same access I have nor how to check that. </p>