From 640dbf705e7449972910c8da90c596cd6f20a7f3 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Fri, 16 Jan 2026 01:26:35 +0100 Subject: [PATCH] Printing/Pdf: Fix detection of WinziPrint.exe to isolate tests properly --- Elwig/Helpers/Printing/Pdf.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Elwig/Helpers/Printing/Pdf.cs b/Elwig/Helpers/Printing/Pdf.cs index 438ae5a..d8091fb 100644 --- a/Elwig/Helpers/Printing/Pdf.cs +++ b/Elwig/Helpers/Printing/Pdf.cs @@ -7,6 +7,7 @@ using System.Drawing.Printing; using System.IO; using System.Linq; using System.Net.Sockets; +using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -15,11 +16,13 @@ using System.Windows; namespace Elwig.Helpers.Printing { public static class Pdf { - private static readonly string WinziPrint = new string[] { App.InstallPath } - .Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? []) - .Select(x => Path.Combine(x, "WinziPrint.exe")) - .Where(File.Exists) - .FirstOrDefault() ?? throw new FileNotFoundException("WiniPrint executable not found"); + private static readonly string WinziPrint = (Assembly.GetEntryAssembly()?.Location.Contains(@"\bin\") ?? false) ? + Path.Combine(Assembly.GetEntryAssembly()!.Location.Split(@"\bin\")[0], "../Installer/Files/WinziPrint.exe") : + new string[] { App.InstallPath } + .Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? []) + .Select(x => Path.Combine(x, "WinziPrint.exe")) + .Where(File.Exists) + .FirstOrDefault() ?? throw new FileNotFoundException("WiniPrint executable not found"); private static Process? WinziPrintProc; public static bool IsReady => WinziPrintProc != null;