Chandra Shekhar Azad
Chandra Shekhar Azad

Reputation: 83

How to Create,set,Read and Delete environment variable using C# and VB.Net programming languages

I want to create a environment variables using C# and VB.Net code and able to Read,Delete and Set values to the new created variable. help me with code to do this process.

Upvotes: 8

Views: 12450

Answers (1)

Grzesiek Danowski
Grzesiek Danowski

Reputation: 467

You can use Environment.SetEnvironmentVariable to create, modify or delete environment variable and Environment.GetEnvironmentVariable for retrieve it.

Reference: https://learn.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=netframework-4.7.2 To delete you set it to null.

Upvotes: 13

Related Questions