Files
client/Services/Printing/PrintFileGuards.cs
2026-05-23 18:16:50 +08:00

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);
}
}
}