[RESOLVED] winform OpenFileDialog
Hello,
The following code shows how to use the openFileDialog to read the contents of a .csv file into a textbox.
Question:
After selecting the file iin the dialog, how do I actually open the file?
remember that I would like to open the .csv file and NOT read it into the textbox.
Dim ts as StreamReader
openFileDialog1.CheckFileExists = true
openFileDialog1.CheckPathExists = true
openFileDialog1.DefaultExt = "csv"
openFileDialog1.Filter = "Text files (*.csv)|*.csv|" + "All files|*.*"
openFileDialog1.Multiselect = false
openFileDialog1.FilterIndex = 2
openFileDialog1.ValidateNames = true
if (openFileDialog1.ShowDialog() = DialogResult.OK)
ts = StreamReader(openFileDialog1.OpenFile())
txtSQL.Text = ts.ReadToEnd()
end if
Thanks
Re: winform OpenFileDialog
Just use the Process.Start method
Process.start(openFileDialog1.FileName)
This open the file in default editor :)
More info : http://msdn.microsoft.com/en-us/libr...50(VS.71).aspx
Hope this helps
Dana
Re: [RESOLVED] winform OpenFileDialog
The thread has be marked as resolved ?
Have got your answer ?
Re: [RESOLVED] winform OpenFileDialog
vb Code:
Me.OpenFileDialog1.Filter = "All Microsoft CSV Files|*.csv"
Me.OpenFileDialog1.Title = "Select the CSV Document to Open"
Me.OpenFileDialog1.FileName = ""
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
If IO.Path.GetExtension(OpenFileDialog1.FileName) = ".CSV" Then
Me.OpenFileDialog1.Dispose()
Me.SendToBack()
System.Diagnostics.Process.Start(OpenFileDialog1.FileName)
End If
End If
Re: [RESOLVED] winform OpenFileDialog
Yes, I have the answer.
Many thanks