using System;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Runtime.InteropServices;
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the path to add: ");
string pathToAdd = Console.ReadLine();
Console.WriteLine($"Path to be added: {pathToAdd}");
// Get the current system environment variables
var envVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);
// Add the new path to the PATH variable
if (envVariables.Contains("Path"))
{
string currentPath = envVariables["Path"] as string;
string newPath = $"{currentPath};{pathToAdd}";
Environment.SetEnvironmentVariable("Path", newPath, EnvironmentVariableTarget.Machine);
Console.WriteLine("New path added successfully!");
}
else
{
Console.WriteLine("PATH variable not found!");
}
}
}