问题描述
我必须检查是否设置了环境变量"DDCI_HOME",我是否使用了以下代码
____________________________________________________________________________________
i have to check whether an environmental variable "DDCI_HOME" is set or not i used following code
____________________________________________________________________________________
String EnviromentPath = System.Environment.GetEnvironmentVariable("DDCI_HOME", 0);
if (EnviromentPath == null)
{
MessageBox.Show("Set the path to DDCI_Home environmentalvariable");
SetEnvVar_AboutBox EnvSetting_obj = new SetEnvVar_AboutBox(compiler_str);
EnvSetting_obj.Show();
}
else
MessageBox.Show(Environment.GetEnvironmentVariable("DDCI_HOME") + "path exist");
否则,请使用带有2个文本字段的AoutBox来提示用户提供envvalue
并使用一个确定按钮.当使用给定环境值并单击确定时,我已使用以下代码声明来设置环境变量.
other wise using an AoutBox with 2 text fields to prompt the user to give envvalue
and using one ok button . when the use give env value and click ok i have used following statement of code to set env variable.
System.Environment.SetEnvironmentVariable(Env_Var_textbox.Text, Env_value_textbox.Text, 0);
没有收到任何错误,但我无法正确设置环境变量,当我们右键单击MYCOMPUTER-> PROPERTIES-> ENVIRONMENTALVARIABLES-> ........
NOT GETTING ANY ERROR BUT I AM UNABLE SET ENV VARIABLE PROPERLY AND I AM UNABLE TO WHEN WE RIGHT CLICK ON MYCOMPUTER->PROPERTIES->ENVIRONMENTALVARIABLES->.....
推荐答案
System.Environment.SetEnvironmentVariable(Env_Var_textbox.Text, Env_value_textbox.Text, EnvironmentVariableTarget.User);
这篇关于以编程方式使用C#进行环境变量路径设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!