我认为环境变量但我不会看到他

编程入门 行业动态 更新时间:2024-10-27 18:25:04
本文介绍了我认为环境变量但我不会看到他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我认为环境变量,但我没有看到他 i在mycomputer-> EnvironmentVariable->中查看 whayyyyyyyy ????? 这是要添加的代码: string value =c:/init.e; if(Environment.GetEnvironmentVariable(init)== null) { System.Environment.SetEnvironmentVariable(init,value); }

i adit a Environment Variable but i dont see him i checked in mycomputer->EnvironmentVariable->in the list there whayyyyyyyy????? this is the code to add : string value="c:/init.e"; if (Environment.GetEnvironmentVariable("init") == null) { System.Environment.SetEnvironmentVariable("init", value); }

推荐答案

什么都不应该返回布尔值。所有方法 SetEnviromentVariable 都是无效的,并且所有方法 GetEnvironmentVariable 都返回字符串值,如果这些变量的值为: msdn.microsoft/en-us/library/ system.environment%28v = vs.110%29.aspx [ ^ ]。 你的我看不到他的问题只是简单地说没有任何意义。 顺便说一句,没有任何人100%确信你确实设置了你的环境变量。首先,如果已找到此变量,则代码不会更改其值。此外,此代码将抛出异常是您的应用程序未获得足够的权限。谁知道,也许你在堆栈的上层堆栈框架上处理异常,所以异常的传播被阻止,所以你可能错过了它(这是许多初学者的常见错误)。
-SA
Nothing is supposed to return Boolean value. All the methods SetEnviromentVariable are void, and all the methods GetEnvironmentVariable return string values, the values if those variables: msdn.microsoft/en-us/library/system.environment%28v=vs.110%29.aspx[^]. Your "I don't see him" question simply makes no sense. By the way, nothing 100% convinced me that you actually set your environment variable. First, if this variable is already found, your code won't change its value. Also, this code will throw exception is your application is not given sufficient permissions. Who knows, maybe you handle exceptions somewhere on upper stack frames of your stack, so the propagation of the exception is blocked, so you might have missed it (this is a usual mistake of many beginners).
—SA

您没有看到环境变量,因为它仅在您的应用程序正在执行的过程中设置。它不会全局设置该值,因此它会出现在所有进程中。 You don't see the environment variable because it's only set in the process that your app is executing in. It does NOT set that value globally so it appears in all processes.

更多推荐

我认为环境变量但我不会看到他

本文发布于:2023-10-22 23:22:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但我   我认为   环境变量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!