-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from j4587698/dev-os
添加Os系统类型
- Loading branch information
Showing
6 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Jx.Toolbox.Utils | ||
{ | ||
/// <summary> | ||
/// 系统类型 | ||
/// </summary> | ||
public static class Os | ||
{ | ||
/// <summary> | ||
/// 是否是Windows系统 | ||
/// </summary> | ||
/// <returns></returns> | ||
public static bool IsWindows() | ||
{ | ||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | ||
} | ||
|
||
/// <summary> | ||
/// 是否是Linux系统 | ||
/// </summary> | ||
/// <returns></returns> | ||
public static bool IsLinux() | ||
{ | ||
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); | ||
} | ||
|
||
/// <summary> | ||
/// 是否是MaxOs系统 | ||
/// </summary> | ||
/// <returns></returns> | ||
public static bool IsMacOs() | ||
{ | ||
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Jx.Toolbox.Utils | ||
{ | ||
public class ProcessUtil | ||
{ | ||
public static void KillProcess(string processName) | ||
{ | ||
foreach (var process in Process.GetProcessesByName(processName)) | ||
{ | ||
process.Kill(); | ||
} | ||
} | ||
|
||
public static void KillProcess(int processId) | ||
{ | ||
Process.GetProcessById(processId).Kill(); | ||
} | ||
|
||
public static void StartProcess(string fileName, string arguments) | ||
{ | ||
Process.Start(fileName, arguments); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters