Setting the value of an existing environment variable to "null" will
delete it from the current process's environment.
This will create a new var & then delete it.
Hope this helps,
Joe
using System.Runtime.InteropServices;
public class Test
{
[DllImport("kernel32.dll", CharSet=CharSet.Auto,
SetLastError=true)]
public static extern bool SetEnvironmentVariable( string
sVarName, string sVarValue );
public Test()
{
}
public string TryThis()
{
string NewEnvVar = "junk";
string NewEnvValue = "testing";
//SetEnvironmentVariable ( NewEnvVar, NewEnvValue );
string sTest = Environment.GetEnvironmentVariable (
"junk" );
SetEnvironmentVariable( "junk", "" );
sTest = Environment.GetEnvironmentVariable ( "junk"
);
return sTest;
}
}