This is a utility class for performing file operations on a printer.

Namespace:  ZSDK_API.Printer
Assembly:  ZSDK_API (in ZSDK_API.dll) Version: 1.1.123.0

Syntax

C#
public interface FileUtil
Visual Basic (Declaration)
Public Interface FileUtil

Examples

Send file contents to a printer.
CopyC#
using System;
using ZSDK_API.Comm;
using ZSDK_API.ApiException;
using ZSDK_API.Printer;

TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
try {
    zebraPrinterConnection.Open();
    ZebraPrinter printer = ZebraPrinterFactory.GetInstance(zebraPrinterConnection);
    // If SAMPLE.ZPL contains a ZPL format, it will be printed
    printer.GetFileUtil().SendFileContents(@"\My Documents\SAMPLE.ZPL");
    zebraPrinterConnection.Close();
} catch (ZebraPrinterConnectionException e) {
    Console.Write(e.Message);
} catch (ZebraPrinterLanguageUnknownException e) {
    Console.Write(e.Message);
} catch (ZebraIllegalArgumentException e) {
    Console.Write(e.Message);
}
CopyVB.NET
Imports ZSDK_API.ApiException
Imports ZSDK_API.Comm
Imports ZSDK_API.Printer    
    Dim zebraPrinterConnection As New TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT)
    Try
        zebraPrinterConnection.Open()
        Dim printer As ZebraPrinter = ZebraPrinterFactory.GetInstance(zebraPrinterConnection)
        ' If SAMPLE.ZPL contains a ZPL format, it will be printed
        printer.GetFileUtil().SendFileContents("\My Documents\SAMPLE.ZPL")
        zebraPrinterConnection.Close()
    Catch e As ZebraPrinterConnectionException
        Console.Write(e.Message)
    Catch e As ZebraPrinterLanguageUnknownException
        Console.Write(e.Message)
    Catch e As ZebraIllegalArgumentException
        Console.Write(e.Message)
    End Try

Examples

Get directory listing from a printer
CopyC#
using System;
using ZSDK_API.Comm;
using ZSDK_API.ApiException;
using ZSDK_API.Printer;

TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
try {
    zebraPrinterConnection.Open();
    ZebraPrinter printer = ZebraPrinterFactory.GetInstance(zebraPrinterConnection);
    // Get a list of the files on the printer
    String[] fileNames = printer.GetFileUtil().RetrieveFileNames();
    zebraPrinterConnection.Close();
} catch (ZebraPrinterConnectionException e) {
    Console.Write(e.Message);
} catch (ZebraPrinterLanguageUnknownException e) {
    Console.Write(e.Message);
} catch (ZebraIllegalArgumentException e) {
    Console.Write(e.Message);
}
CopyVB.NET
Imports System
Imports System.Threading
Imports ZSDK_API.Comm
Imports ZSDK_API.ApiException
Imports System.Text
Imports System.IO.Ports
Imports ZSDK_API.Printer
   Dim zebraPrinterConnection As New TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT)
   Try
       zebraPrinterConnection.Open()
       Dim printer As ZebraPrinter = ZebraPrinterFactory.GetInstance(zebraPrinterConnection)
       ' Get a list of the files on the printer
       Dim fileNames As [String]() = printer.GetFileUtil().RetrieveFileNames()
       zebraPrinterConnection.Close()
   Catch e As ZebraPrinterConnectionException
       Console.Write(e.Message)
   Catch e As ZebraPrinterLanguageUnknownException
       Console.Write(e.Message)
   Catch e As ZebraIllegalArgumentException
       Console.Write(e.Message)
   End Try

See Also