22 lines
604 B
C#
22 lines
604 B
C#
using CloudPrint.Client.Models;
|
|
using System.IO;
|
|
|
|
namespace CloudPrint.Client.Services.Printing;
|
|
|
|
internal static class PrintFileGuards
|
|
{
|
|
public static void EnsurePrintableFile(PrintJob job)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(job);
|
|
|
|
if (string.IsNullOrWhiteSpace(job.PrinterName))
|
|
{
|
|
throw new InvalidOperationException("打印机名称不能为空");
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(job.FilePath) || !File.Exists(job.FilePath))
|
|
{
|
|
throw new FileNotFoundException("待打印文件不存在", job.FilePath);
|
|
}
|
|
}
|
|
} |