PrintServer Constructors

Definition

Initializes a new instance of the PrintServer class.

Overloads

PrintServer()

Initializes a new instance of the PrintServer class.

PrintServer(PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that represents the local print server and assigns it the specified PrintSystemDesiredAccess.

PrintServer(String)

Initializes a new instance of the PrintServer class that has the specified path.

PrintServer(String, PrintServerIndexedProperty[])

Initializes a new instance of the PrintServer class by using the specified PrintServerIndexedProperty array to determine which properties will be initialized.

PrintServer(String, PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path and the needed access.

PrintServer(String, String[])

Initializes a new instance of the PrintServer class that has the specified path and properties filter.

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class and provides the specified path, the PrintServerIndexedProperty array, and the needed access.

PrintServer(String, String[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path, properties filter, and the needed access.

PrintServer()

Initializes a new instance of the PrintServer class.

C#
public PrintServer();

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that represents the local print server and assigns it the specified PrintSystemDesiredAccess.

C#
public PrintServer(System.Printing.PrintSystemDesiredAccess desiredAccess);

Parameters

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

The PrintServer will be initialized with the local print server's properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String)

Initializes a new instance of the PrintServer class that has the specified path.

C#
public PrintServer(string path);

Parameters

path
String

The name and complete path of the print server.

Examples

The following example shows how to use this constructor to create an instance of PrintServer.

C#

// Create a PrintServer
// "theServer" must be a print server to which the user has full print access.
PrintServer myPrintServer = new PrintServer(@"\\theServer");

// List the print server's queues
PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
String printQueueNames = "My Print Queues:\n\n";
foreach (PrintQueue pq in myPrintQueues)
{
    printQueueNames += "\t" + pq.Name + "\n";
}
Console.WriteLine(printQueueNames);
Console.WriteLine("\nPress Return to continue.");
Console.ReadLine();

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String, PrintServerIndexedProperty[])

Initializes a new instance of the PrintServer class by using the specified PrintServerIndexedProperty array to determine which properties will be initialized.

C#
public PrintServer(string path, System.Printing.PrintServerIndexedProperty[] propertiesFilter);

Parameters

path
String

The complete path and name of the print server.

propertiesFilter
PrintServerIndexedProperty[]

The properties that the constructor initializes.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String, PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path and the needed access.

C#
public PrintServer(string path, System.Printing.PrintSystemDesiredAccess desiredAccess);

Parameters

path
String

The name and complete path of the print server.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Examples

The following example shows how to use this constructor to survey all printers for possible error status.

C#
// Survey queue status for every queue on every print server
String line;
String statusReport = "\n\nAny problem states are indicated below:\n\n";
while ((line = fileOfPrintServers.ReadLine()) != null)
 {
     PrintServer myPS = new PrintServer(line, PrintSystemDesiredAccess.AdministrateServer);
     PrintQueueCollection myPrintQueues = myPS.GetPrintQueues();
     statusReport = statusReport + "\n" + line;
     foreach (PrintQueue pq in myPrintQueues)
     {
         pq.Refresh();
         statusReport = statusReport + "\n\t" + pq.Name + ":";
         if (useAttributesResponse == "y")
         {
             TroubleSpotter.SpotTroubleUsingQueueAttributes(ref statusReport, pq);
             // TroubleSpotter class is defined in the complete example.
         }
         else
         {
             TroubleSpotter.SpotTroubleUsingProperties(ref statusReport, pq);
         }                 
     }// end for each print queue
 }// end while list of print servers is not yet exhausted

fileOfPrintServers.Close();
Console.WriteLine(statusReport);
Console.WriteLine("\nPress Return to continue.");
Console.ReadLine();

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String, String[])

Initializes a new instance of the PrintServer class that has the specified path and properties filter.

C#
public PrintServer(string path, string[] propertiesFilter);

Parameters

path
String

The name and complete path of the print server.

propertiesFilter
String[]

An array of the names of properties that the constructor initializes.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class and provides the specified path, the PrintServerIndexedProperty array, and the needed access.

C#
public PrintServer(string path, System.Printing.PrintServerIndexedProperty[] propertiesFilter, System.Printing.PrintSystemDesiredAccess desiredAccess);

Parameters

path
String

The complete path and name of the print server.

propertiesFilter
PrintServerIndexedProperty[]

The properties that the constructor initializes.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

PrintServer(String, String[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path, properties filter, and the needed access.

C#
public PrintServer(string path, string[] propertiesFilter, System.Printing.PrintSystemDesiredAccess desiredAccess);

Parameters

path
String

The name and complete path of the print server.

propertiesFilter
String[]

An array of the names of properties that the constructor initializes.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10