|
-
Jul 28th, 2008, 06:04 AM
#1
Thread Starter
Fanatic Member
[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
-
Jul 28th, 2008, 06:26 AM
#2
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
-
Jul 28th, 2008, 06:37 AM
#3
Re: [RESOLVED] winform OpenFileDialog
The thread has be marked as resolved ?
Have got your answer ?
-
Jul 28th, 2008, 06:54 AM
#4
Frenzied Member
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
-
Jul 28th, 2008, 06:59 AM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] winform OpenFileDialog
Yes, I have the answer.
Many thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|