Diagnostics
How do I use Diagnostics
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: VSCode.cs
Copy
439 static void CallVSCode(string args)
440 {
441 System.Diagnostics.Process proc = new System.Diagnostics.Process();
442 if(!VSCodeExists(CodePath))
443 {
444 PrintNotFound(CodePath);
445 return;
446 }
447
448#if UNITY_EDITOR_OSX
449 proc.StartInfo.FileName = "open";
450
451 // Check the path to see if there is "Insiders"
452 if (CodePath.Contains("Insiders"))
453 {
454 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCodeInsiders\" --args " + args.Replace(@"\", @"\\");
455 }
456 else
457 {
458 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCode\" --args " + args.Replace(@"\", @"\\");
459 }
460
461 proc.StartInfo.UseShellExecute = false;
462#elif UNITY_EDITOR_WIN
463 proc.StartInfo.FileName = CodePath;
464 proc.StartInfo.Arguments = args;
465 proc.StartInfo.UseShellExecute = false;
466#else
467 proc.StartInfo.FileName = CodePath;
468 proc.StartInfo.Arguments = args.Replace(@"\", @"\\");
469 proc.StartInfo.UseShellExecute = false;
470#endif
471 proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
472 proc.StartInfo.CreateNoWindow = true;
473 proc.StartInfo.RedirectStandardOutput = true;
474 proc.Start();
475 }
File name: frmMainMenu.cs
Copy
62 private void notepadToolStripMenuItem_Click(object sender, EventArgs e)
63 {
64 System.Diagnostics.Process.Start("Notepad.exe");
65 }
File name: frmMainMenu.cs
Copy
67 private void calculatorToolStripMenuItem_Click(object sender, EventArgs e)
68 {
69 System.Diagnostics.Process.Start("Calc.exe");
70 }
File name: frmMainMenu.cs
Copy
72 private void wordpadToolStripMenuItem_Click(object sender, EventArgs e)
73 {
74 System.Diagnostics.Process.Start("Wordpad.exe");
75 }
File name: frmMainMenu.cs
Copy
77 private void taskManagerToolStripMenuItem_Click(object sender, EventArgs e)
78 {
79 System.Diagnostics.Process.Start("TaskMgr.exe");
80 }
File name: frmMainMenu.cs
Copy
82 private void mSWordToolStripMenuItem_Click(object sender, EventArgs e)
83 {
84 System.Diagnostics.Process.Start("Winword.exe");
85 }
File name: notepad1.cs
Copy
688 private void toolStripStatusLabel1_Click(object sender, EventArgs e)
689 {
690 System.Diagnostics.Process.Start("https://allice9554.000webhostapp.com/");
691 }
Diagnostics 99 lượt xem
Gõ tìm kiếm nhanh...