/* Click the button of the form made in C# to open the desired file */ using using using using
System; System.Windows.Forms; System.Drawing; System.Diagnostics;
class ButtonForm : Form { Button MyButton; Button MyButton2; public ButtonForm() { Text = "Syed Arbab Ahmed Assignment EP-046142"; MyButton = new Button(); MyButton.Text = "Click me to open your desired file"; MyButton.Location = new Point(100, 200); MyButton2 = new Button(); MyButton2.Text = " Click me to open your desired file no. 2"; MyButton2.Location = new Point(100, 100); // Add button event handler to list. MyButton.Click += new EventHandler(MyButtonClick); MyButton2.Click += new EventHandler(MyButton2Click); Controls.Add(MyButton); Controls.Add(MyButton2); } [STAThread] public static void Main() { ButtonForm skel = new ButtonForm(); Application.Run(skel); Application.EnableVisualStyles(); Application.Run(new ButtonForm()); //skel.BackColor = (1,1,1); } // Handler for MyButton. Process TheProcessYouNamed; private void MyButtonClick(object sender, EventArgs e) { { TheProcessYouNamed = Process.Start(@"E:\Check.txt");//@ to avoid Unrecognized escape sequence otherwise ERROR C:\Documents and Settings\tuser\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 39
} }
TheProcessYouNamed.CloseMainWindow();
Process TheProcessYouNamed2; private void MyButton2Click(object sender, EventArgs e) { {
TheProcessYouNamed2 = Process.Start(@"c:\RR.txt");//@ to avoid Unrecognized escape sequence otherwise ERROR C:\Documents and Settings\tuser\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 39 TheProcessYouNamed2.CloseMainWindow(); } } } /* Syed Arbab Ahmed from Karachi, Pakistan. */