-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathLogViewerHelper.cs
More file actions
54 lines (48 loc) · 1.45 KB
/
LogViewerHelper.cs
File metadata and controls
54 lines (48 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace SyncPro.Tracing
{
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
public static class LogViewerHelper
{
public static void LaunchLogViewer(
string viewerArgs,
bool closeOnProcessExit)
{
string[] searchPaths =
{
".",
#if DEBUG
@"..\..\..\SyncProLogViewer\bin\Debug"
#endif
};
string exePath = null;
string searchBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
foreach (string searchPath in searchPaths)
{
string path = Path.Combine(searchBase, searchPath, "SyncProLogViewer.exe");
if (File.Exists(path))
{
exePath = path;
break;
}
}
if (exePath != null)
{
string args = viewerArgs;
if (closeOnProcessExit)
{
args += string.Format(" /closeOnExit {0}", Process.GetCurrentProcess().Id);
}
using (Process process = Process.Start(exePath, args))
{
if (process != null && process.HasExited)
{
throw new Exception("Failed to start JsonLogViewer");
}
}
}
}
}
}