How to open a file in the application using openFileDialog
-
:doh: Can someone please help me to open a file in the application using openFileDialog. I have a button "Open File" > which then opens an openFileDialog window, I then select the file and click Open, but it does not want to open. I do get the path and everything, but it does not want to open. Maybe I am using the wrong code. Here is a snippet of my code: //Opens the file and populates the datagrid private void btnOpenFile_Click(object sender, EventArgs e) { ofdExcelDoc.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"; if (ofdExcelDoc.ShowDialog() == DialogResult.OK) { ofdExcelDoc.OpenFile(); try { // Attempt to open the file and output its contents to a text box Stream stream; if ((stream = ofdExcelDoc.OpenFile()) != null) { StreamReader reader = new StreamReader(stream); //dgFileInfo.DataSource = reader.ReadToEnd(); txtOutput.Text = reader.ReadToEnd(); stream.Close(); } } catch (Exception ex) { MessageBox.Show("There was an Error: " + ex.Message); } } } } Mvelo Walaza Developer Telkom SA
-
:doh: Can someone please help me to open a file in the application using openFileDialog. I have a button "Open File" > which then opens an openFileDialog window, I then select the file and click Open, but it does not want to open. I do get the path and everything, but it does not want to open. Maybe I am using the wrong code. Here is a snippet of my code: //Opens the file and populates the datagrid private void btnOpenFile_Click(object sender, EventArgs e) { ofdExcelDoc.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"; if (ofdExcelDoc.ShowDialog() == DialogResult.OK) { ofdExcelDoc.OpenFile(); try { // Attempt to open the file and output its contents to a text box Stream stream; if ((stream = ofdExcelDoc.OpenFile()) != null) { StreamReader reader = new StreamReader(stream); //dgFileInfo.DataSource = reader.ReadToEnd(); txtOutput.Text = reader.ReadToEnd(); stream.Close(); } } catch (Exception ex) { MessageBox.Show("There was an Error: " + ex.Message); } } } } Mvelo Walaza Developer Telkom SA
remove the first occurance of ofdEcvelDoc.OpenFile();
-
:doh: Can someone please help me to open a file in the application using openFileDialog. I have a button "Open File" > which then opens an openFileDialog window, I then select the file and click Open, but it does not want to open. I do get the path and everything, but it does not want to open. Maybe I am using the wrong code. Here is a snippet of my code: //Opens the file and populates the datagrid private void btnOpenFile_Click(object sender, EventArgs e) { ofdExcelDoc.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"; if (ofdExcelDoc.ShowDialog() == DialogResult.OK) { ofdExcelDoc.OpenFile(); try { // Attempt to open the file and output its contents to a text box Stream stream; if ((stream = ofdExcelDoc.OpenFile()) != null) { StreamReader reader = new StreamReader(stream); //dgFileInfo.DataSource = reader.ReadToEnd(); txtOutput.Text = reader.ReadToEnd(); stream.Close(); } } catch (Exception ex) { MessageBox.Show("There was an Error: " + ex.Message); } } } } Mvelo Walaza Developer Telkom SA
-
:doh: Can someone please help me to open a file in the application using openFileDialog. I have a button "Open File" > which then opens an openFileDialog window, I then select the file and click Open, but it does not want to open. I do get the path and everything, but it does not want to open. Maybe I am using the wrong code. Here is a snippet of my code: //Opens the file and populates the datagrid private void btnOpenFile_Click(object sender, EventArgs e) { ofdExcelDoc.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"; if (ofdExcelDoc.ShowDialog() == DialogResult.OK) { ofdExcelDoc.OpenFile(); try { // Attempt to open the file and output its contents to a text box Stream stream; if ((stream = ofdExcelDoc.OpenFile()) != null) { StreamReader reader = new StreamReader(stream); //dgFileInfo.DataSource = reader.ReadToEnd(); txtOutput.Text = reader.ReadToEnd(); stream.Close(); } } catch (Exception ex) { MessageBox.Show("There was an Error: " + ex.Message); } } } } Mvelo Walaza Developer Telkom SA
replace
ofdExcelDoc.OpenFile();
with
System.Diagnostics.Process.Start(ofdExcelDoc.FileName);
i hope it will work
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
replace
ofdExcelDoc.OpenFile();
with
System.Diagnostics.Process.Start(ofdExcelDoc.FileName);
i hope it will work
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
glad to know :)
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can