Bend.Settings.AppendToPath_Click C# (CSharp) Method

AppendToPath_Click() private method

private AppendToPath_Click ( object sender, RoutedEventArgs e ) : void
sender object
e System.Windows.RoutedEventArgs
return void
        private void AppendToPath_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RegistryKey HKCU_ENVIRONMENT = Registry.CurrentUser.CreateSubKey("Environment");
                string BendExePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                string bendDirectory = System.IO.Path.GetDirectoryName(BendExePath);
                string currentPath;
                if (HKCU_ENVIRONMENT.GetValue("Path") != null)
                {
                    currentPath = HKCU_ENVIRONMENT.GetValue("Path").ToString();
                    if (currentPath.IndexOf(bendDirectory) >= 0)
                    {
                        // We are already in the path nothing to do here.
                        throw new Exception();
                    }
                }
                else
                {
                    currentPath = "";
                }
                currentPath = bendDirectory + ";" + currentPath;
                HKCU_ENVIRONMENT.SetValue("Path", currentPath);
            }
            catch
            {
            }
        }