Hanson.Common.SystemUtils 2.0.0

dotnet add package Hanson.Common.SystemUtils --version 2.0.0                
NuGet\Install-Package Hanson.Common.SystemUtils -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hanson.Common.SystemUtils" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hanson.Common.SystemUtils --version 2.0.0                
#r "nuget: Hanson.Common.SystemUtils, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hanson.Common.SystemUtils as a Cake Addin
#addin nuget:?package=Hanson.Common.SystemUtils&version=2.0.0

// Install Hanson.Common.SystemUtils as a Cake Tool
#tool nuget:?package=Hanson.Common.SystemUtils&version=2.0.0                

README

Hanson.Common.Utils

主要功能

  1. 提供 Process 相關功能
    • 執行系統執行程序 StartProcess
  2. 提供 Network 相關功能
    • Ping IP (IPv4)
    • 驗證 IPv4 的字串
    • 取得網路資訊 (連線狀態、介面型別、MAC、IP & 設備描述)

前置條件

  • 開發環境需具備 .Net 8.0
  • 運行於 Windows Platform (x64)
  • 運行於 Linux Platform (x64)
  • 運行於 Raspberry PI Platform (x64)

安裝方式

授權

此專案採用的 License為 Apache-2.0

使用範例

命名空間

using Hanson.Common.Utils;
  • Process 相關使用範例
private void Sample()
{
    var path = @"C:\";
	var command = "test.exe";
    
    // 執行指定程序
	bool result = SystemUtils.StartProcess(path, command);
    Console.WriteLine($"程序({command}) - 執行結果: {result}");

}
  • Network 相關使用範例
private void Sample()
{
    // 使用正確的 IP 字串格式
    string ipAddress = "127.0.0.1";
    bool result = SystemUtils.VerifyIPv4Format(ipAddress);
	Console.WriteLine($"驗證IP結果({ipAddress}) - 執行結果: TRUE");
    
    // 使用錯誤的 IP 字串格式
    string errorIpAddress = "127.0.0.x";
    result = SystemUtils.VerifyIPv4Format(errorIpAddress);
	Console.WriteLine($"驗證IP結果({errorIpAddress}) - 執行結果: FALSE");
    
    // Ping IP
    string ip = "127.0.0.1";
    result = SystemUtils.PingIPv4(ip);
    Console.WriteLine($"Ping IP ({ip}) - 執行結果: {result}");

    // 取得系統網路狀態 EthernetInfo
    EthernetInfo[] info = SystemUtils.GetEthernetInfo();
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Hanson.Common.SystemUtils:

Package Downloads
Hanson.AutoUpdater

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 91 11/30/2024
1.0.0 175 2/16/2024