Skip to content

Commit af6b705

Browse files
committed
Fix to move source file to avoid conflicts
1 parent 7664b48 commit af6b705

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Samples/DesktopBridge/Launcher/Program.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/* ------------------------------------------------------------------------- */
1818
namespace Cube.Psa.DesktopBridge;
1919

20+
using System;
2021
using System.Diagnostics;
2122
using System.IO;
2223
using Windows.Storage;
@@ -46,8 +47,11 @@ static void Main()
4647
var dir = ApplicationData.Current.GetPublisherCacheFolder("printing");
4748
if (dir is null) return;
4849

49-
var src = Path.Combine(dir.Path, "source.ps");
50-
if (!File.Exists(src)) return;
50+
var raw = Path.Combine(dir.Path, "source.ps");
51+
if (!File.Exists(raw)) return;
52+
53+
var src = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
54+
File.Move(raw, src);
5155

5256
try
5357
{
@@ -60,6 +64,10 @@ static void Main()
6064
psi.ArgumentList.Add(src);
6165
Process.Start(psi)?.WaitForExit();
6266
}
63-
finally { if (File.Exists(src)) File.Delete(src); }
67+
finally
68+
{
69+
if (File.Exists(raw)) File.Delete(raw);
70+
if (File.Exists(src)) File.Delete(src);
71+
}
6472
}
6573
}

0 commit comments

Comments
 (0)