BF2Statistics.MedalData.NewProfilePrompt.CreateBtn_Click C# (CSharp) Method

CreateBtn_Click() private method

private CreateBtn_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void CreateBtn_Click(object sender, EventArgs e)
        {
            // Trim input
            string Name = ProfileName.Text.Trim();

            // Make sure we dont have an empty string!
            if (String.IsNullOrEmpty(Name))
            {
                MessageBox.Show("Please enter a profile name.", "Error");
                return;
            }

            // Make sure the named profile doesnt exist!
            if (MedalDataEditor.Profiles.Contains(Name.ToLower()))
            {
                MessageBox.Show("This profile name already exists. Please try a different profile name.", "Error");
                return;
            }

            // Write default medal data
            try
            {
                File.WriteAllText(
                    Path.Combine(MedalDataEditor.PythonPath, "medal_data_" + Name + ".py"),
                    String.Concat(
                        Program.GetResourceAsString("BF2Statistics.MedalData.PyFiles.functions.py"),
                        Program.GetResourceAsString("BF2Statistics.MedalData.PyFiles.medal_data_xpack.py")
                    )
                );
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "An exception was thrown while trying to create a medal data file!"
                        + Environment.NewLine + Environment.NewLine
                        + "Message: " + ex.Message,
                    "Error"
                );
                this.DialogResult = DialogResult.Abort;
                this.Close();
            }

            // and close!
            LastProfileName = Name;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }