-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
29 lines (24 loc) · 947 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace MyApp // Note: actual namespace depends on the project name.
{
public class Program
{
public static void Main(string[] args)
{
if(args.Length == 0 || string.IsNullOrWhiteSpace(args[0]))
{
Console.WriteLine("Path required, please use it like this: concatpath {your_path_here}");
}
var pathToAdd = args[0];
var currentPathValue = GetEnvironmentVariable("Path");
var newPath = currentPathValue != null
? $"{currentPathValue};{pathToAdd}"
: pathToAdd;
Environment.SetEnvironmentVariable("Path", newPath, EnvironmentVariableTarget.User);
}
public static string? GetEnvironmentVariable(string name)
{
var value = Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.User);
return value;
}
}
}