How to read a user environment variable in C#?

后端 未结 4 2029
北荒
北荒 2021-02-12 12:56

How can I read a user specific environment variable? I know how to get a system wide one, like

Environment.GetEnvironmentVariable(\"SOMETHING\");
4条回答
  •  悲&欢浪女
    2021-02-12 13:39

    It's the same method, just set the second parameter to be User as:

    System.Environment.GetEnvironmentVariable("varName", EnvironmentVariableTarget.User);
    

提交回复
热议问题