Feedback

Beliebige Dateien drucken

Sprache: C#

Mit diesem Snippet kann man beliebige Dateien drucken. BSP: PrintFile("D:\Test\Test.pdf");
/// <summary>
/// Prints the file.
/// </summary>
/// <param name="fullPath">The full path.</param>
private static void PrintFile(string fullPath)
{
    FileInfo fileInfo = new FileInfo(fullPath);

    if(!fileInfo.Exists)
    {
        throw new FileNotFoundException();
    }

    var printProcess = new Process();
    printProcess.StartInfo.FileName = fullPath;
    printProcess.StartInfo.UseShellExecute = true;
    printProcess.StartInfo.Verb = "print";
    printProcess.Start();
}
/// <summary>
/// Prints the file.
/// </summary>
/// <param name="fullPath">The full path.</param>
private static void PrintFile(string fullPath)
{
    FileInfo fileInfo = new FileInfo(fullPath);

    if(!fileInfo.Exists)
    {
        throw new FileNotFoundException();
    }

    var printProcess = new Process();
    printProcess.StartInfo.FileName = fullPath;
    printProcess.StartInfo.UseShellExecute = true;
    printProcess.StartInfo.Verb = "print";
    printProcess.Start();
}

3 Kommentare