5
Answers

Opening .exe file using OpenFileDialog() in C#

p c

p c

16y
7.2k
1
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)