p c

p c

  • NA
  • 20
  • 27.3k

Opening .exe file using OpenFileDialog() in C#

Jan 31 2008 8:58 AM
Hi, i want open an .exe file using OpenFileDialog() in C#
The code i ve used is -

               
                Stream strm;
                StreamReader reader;
                try
                {
                    strm = OpenFileDialog1.OpenFile();
                    reader = new StreamReader(strm);
                }
                catch (Exception err)
                {
                    string Message = err.Message + "\n\nCannot open "
                                     + OpenFileDialog1.FileName;
                    MessageBox.Show(Message, "Open error",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                    return;
                }
                reader.ReadToEnd();
                reader.Close();
                strm.Close();


But, I m getting an error..
Can anybody tell me the cause....
Thanx in advance


Answers (5)