Example #1
0
        private void SwitchPy(string TargetPath, string OldPath)
        {
            if (!string.IsNullOrEmpty(TargetPath) && !string.IsNullOrEmpty(OldPath))
            {
                textBox3.Text = LoadPath();
                var pathList = textBox3.Text.Split(';');

                for (int i = 0; i < pathList.Length; i++)
                {
                    var item = pathList[i];
                    if (item.ToLower().Trim().StartsWith(OldPath.ToLower()))
                    {
                        item = item.Replace(OldPath, TargetPath);
                    }
                    pathList[i] = item;
                }
                var newPathValue = string.Join(";", pathList);
                SysEnvironment.SetSysEnvironment("PATH", newPathValue);
                lblMsg.Text   = "PATH Saved! - - " + DateTime.Now.ToString();
                textBox3.Text = LoadPath();
            }
            else
            {
                BB();
            }
        }
Example #2
0
 private string LoadPath()
 {
     return(SysEnvironment.GetSysEnvironmentByName("PATH"));
 }
Example #3
0
 private void button3_Click(object sender, EventArgs e)
 {
     SysEnvironment.SetSysEnvironment("PATH", textBox3.Text);
     lblMsg.Text = "PATH Saved! - - " + DateTime.Now.ToString();
 }