2012-05-31 5 views
1

C#에서 일부 코드를 alterIWnet.ini 파일에 저장하기위한 코드가 있으므로 alterIWnet.ini 파일에 저장된 데이터가 닫히면 양식이 닫힙니다.푸시 저장 버튼을 누른 후 123.exe를 시작하는 방법은 무엇입니까?

그러나 저장 버튼을 누르면 alterIWnet.ini 파일에 저장된 데이터가 사라지고 그 다음에 123.exe 파일이 열립니다.

이 작업에 추가해야하는 코드는 무엇입니까?

내 C# 코드 : 그래서 같은

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(); 

    } 
} 
} 
+1

Process.Start() – jglouie

답변

1

이 네임 스페이스에 선 아래 추가

가져 오기 System.Diagnostics.Process가;

버튼의 클릭 이벤트에 아래 라인을 추가하십시오.

Process.Start ("123.exe");

+0

고맙습니다. 정확히 123..exe를 저장 버튼을 눌러 저장 한 후에 추가해야합니다. - ramin esmailinagad –

+0

고맙습니다 ... 해결되었습니다. –

4

사용 System.Diagnostics. Process . Start() :

Process.Start("123.exe"); 
+0

감사합니다. 정확히 123000을 저장 버튼으로 푸시 한 후 추가해야합니다. 시작 하시겠습니까? –

+0

System.Diagnostics.Process를 사용하여 this를 추가합니다. 및 Process.Start ("123.exe"); 하지만이 오류가 발생합니다 : 이름 '프로세스'현재 contex 존재하지 않습니다 –

+0

bin 폴더에 123.exe를 추가하십시오. 또는 .exe의 전체 경로를 Start() 이벤트의 매개 변수로 지정하십시오. –

관련 문제