C# 获取系统环境数据

using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Threading;

namespace DelegateTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Print("-----------------------------------");
            Print("Command:" + Environment.CommandLine);
            Print("CurentDir:"+Environment.CurrentDirectory);
            Print("Version:"+Environment.Version);
            Print("OS Version:"+Environment.OSVersion);
            Print("Machine:"+Environment.MachineName);
            Print("Memory:" + Environment.WorkingSet);
            Print("\n-----------------------------------");
            string[] arguments = Environment.GetCommandLineArgs();
            foreach (string str in arguments)
            {
                Print(str);
            }
            Print("\n-----------------------------------");
            string[] drivers = Environment.GetLogicalDrives();
            foreach (string str in drivers)
            {
                Print(str);
            }
            Print("\n-----------------------------------");
            Print("Path:"+Environment.GetEnvironmentVariable("Path"));
            string[] paths = Environment.GetEnvironmentVariable("Path").Split(;);
            foreach (string p in paths)
            {
                Print(p);
            }
        }

        public static void Print(string str)
        {
            Console.WriteLine(str);
        }
    }
}

 

C# 获取系统环境数据

上一篇:用C#实现获取文件夹大小的源代码


下一篇:C# 模拟页面登录