Microsoft.Scripting.PlatformAdaptationLayer.SetEmptyEnvironmentVariable C# (CSharp) Method

SetEmptyEnvironmentVariable() private method

private SetEmptyEnvironmentVariable ( string key ) : void
key string
return void
        private static void SetEmptyEnvironmentVariable(string key) {
            // System.Environment.SetEnvironmentVariable interprets an empty value string as 
            // deleting the environment variable. So we use the native SetEnvironmentVariable 
            // function here which allows setting of the value to an empty string.
            // This will require high trust and will fail in sandboxed environments
            if (!NativeMethods.SetEnvironmentVariable(key, String.Empty)) {
                throw new ExternalException("SetEnvironmentVariable failed", Marshal.GetLastWin32Error());
            }
        }
#endif