C# 打印环境变量

C#代码如下:

using System;
namespace evApplication
{
    class ev
    {
        static void Main(string[] args)
        {
            string e_variable = Environment.GetEnvironmentVariable("Path");
            string[] ev_list = e_variable.Split(';');
            
            foreach(string path in ev_list)
                Console.WriteLine(path);
            
            
            Console.ReadKey();
        }
    }
}

代码保存在后缀名为cs的文件里。

通过cmd命令行编译.cs后缀的文件,生成exe文件:

运行exe文件,可以看到已经列出Path环境变量了:

猜你喜欢

转载自www.cnblogs.com/clb-blog/p/11202940.html
今日推荐