CPlan.W3LF.frmMain.btnStart_Click C# (CSharp) Метод

btnStart_Click() приватный Метод

Starts Warcraft III.
private btnStart_Click ( object sender, EventArgs e ) : void
sender object The source of the event.
e EventArgs An System.EventArgs that contains no event data.
Результат void
        private void btnStart_Click(object sender, EventArgs e)
        {
            // Create a dummy to save the path to war3.exe
            string w3path = @"C:\Program Files\Warcraft III\war3.exe";
            // Check if war3.exe exists in the default installation directory.
            if (File.Exists(w3path))
                Loader.RunW3(); // If it does, start Warcraft III!
            else
            {
                // If it doesn't try the registry!
                try // However; Do it safe, it can give an exception, so catch and handle it.
                {
                    // Try to get the value from the registry...
                    w3path = Path.Combine(Registry.CurrentUser.OpenSubKey(@"Software\Blizzard Entertainment\Warcraft III").GetValue("InstallPath").ToString(), "war3.exe");
                }
                catch (Exception)
                {
                    // Seems like it gave an error, let the user find it for himself...
                    MessageBox.Show("An exception was thrown while getting the installation path from the registry. Please select the location of war3.exe manually.",
                        "Registry exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Create a new form that will help your users to find war3.exe.
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.Filter = "Executable files|*.exe|All files|*.*"; // Create a filter that will only allow extensions like: *.exe or everything else. (*.*).
                    ofd.RestoreDirectory = true;
                    if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        w3path = ofd.FileName;
                }
                // Check for war3.exe once more, if it doesn't give a message and exit the method.
                if (File.Exists(w3path))
                    Loader.RunW3();
                else
                    MessageBox.Show("war3.exe was nowhere to find, please retry by pressing the Start Warcraft III button.", "No war3.exe", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }