private void cmdPurgeQueue_Click(object sender, RoutedEventArgs e) { if (lstQueues.SelectedValue != null) { PrintQueue queue = printServer.GetPrintQueue(lstQueues.SelectedValue.ToString()); queue.Purge(); } }
public string ClearQueue() { LocalPrintServer ps = new LocalPrintServer(); PrintQueue pq = ps.GetPrintQueue("");/// ( DefaultPrintQueue; pq.Purge(); return("Ok"); }
protected static void PurgeLocalPrintQueues() { LocalPrintServer localMachine = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer); foreach (var queue in localMachine.GetPrintQueues()) { // Need to create another print queue object with sufficient privileges to purge PrintQueue privilegedQueue = new PrintQueue(localMachine, queue.Name, PrintSystemDesiredAccess.AdministratePrinter); privilegedQueue.Purge(); } }
private static void PurgeRemotePrintQueue(string serverName, string printQueueName) { try { using (PrintServer ps = new PrintServer(@"\\" + serverName)) { using (PrintQueue queue = new PrintQueue(ps, printQueueName, PrintSystemDesiredAccess.AdministratePrinter)) { queue.Purge(); } } } catch (Exception e) { TraceFactory.Logger.Debug(e); } }
public static bool CleanPrintQueue(string PrinterName) { try { LocalPrintServer _printServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministratePrinter); PrintQueue printqueue = new PrintQueue(_printServer, PrinterName); printqueue.Refresh(); if (printqueue.NumberOfJobs != 0) { printqueue.Purge(); } return(true); } catch (Exception) { return(false); } }