1

I have some code in C# it is for saving some data in alterIWnet.ini file so after saved data in alterIWnet.ini file the form gets closed.

But after I push the save button I wan the data saved in alterIWnet.ini file and then open the 123.exe file after that.

What code must I add to this job?

My C# code:

namespace configure_alteriwnet
{
using configure_alteriwnet.Properties;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

public class frmConfig : Form
{
    private Button button1;
    private IContainer components;
    private Label label1;
    private PictureBox pictureBox1;
    private TextBox textBox1;

    public frmConfig()
    {
        this.InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if ((this.textBox1.Text == "") || (this.textBox1.Text.Length > 80))
        {
            MessageBox.Show("The entered nickname is invalid.", "alterIWnet", MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }
        else
        {
            new IniReader(@".\\alterIWnet.ini").Write("Configuration", "Nickname", this.textBox1.Text);
            base.Close();
        }
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing && (this.components != null))
        {
            this.components.Dispose();
        }
        base.Dispose(disposing);
    }

    private void frmConfig_Load(object sender, EventArgs e)
    {
        this.textBox1.Text = new IniReader(@".\\alterIWnet.ini").ReadString("Configuration", "Nickname", "UnknownPlayer");
    }

    private void InitializeComponent()
    {
        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.label1 = new System.Windows.Forms.Label();
        this.button1 = new System.Windows.Forms.Button();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        this.SuspendLayout();
        // 
        // pictureBox1
        // 
        this.pictureBox1.Location = new System.Drawing.Point(13, 13);
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.Size = new System.Drawing.Size(650, 120);
        this.pictureBox1.TabIndex = 0;
        this.pictureBox1.TabStop = false;
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(245, 156);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(200, 20);
        this.textBox1.TabIndex = 1;
        this.textBox1.Text = "UnknownPlayer";
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.ForeColor = System.Drawing.Color.White;
        this.label1.Location = new System.Drawing.Point(316, 140);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(58, 13);
        this.label1.TabIndex = 2;
        this.label1.Text = "Nickname:";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(299, 182);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 3;
        this.button1.Text = "Save";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // frmConfig
        // 
        this.BackColor = System.Drawing.Color.Black;
        this.ClientSize = new System.Drawing.Size(674, 215);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.pictureBox1);
        this.Name = "frmConfig";
        this.Text = "alterIWnet MW2 configuration";
        this.Load += new System.EventHandler(this.frmConfig_Load);
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        this.ResumeLayout(false);
        this.PerformLayout();

    }
}
}
4

2 回答 2

4

Use System.Diagnostics.Process.Start() like so:

Process.Start("123.exe");
于 2012-05-31T15:43:58.047 回答
1

在命名空间中添加以下行

导入 System.Diagnostics.Process;

在按钮的单击事件中添加以下行。

Process.Start("123.exe");

于 2012-05-31T15:45:31.037 回答