|
-
October 23rd, 2002, 11:57 PM
#1
SaveFileDialog
I need help with saving value from text box to a file using SaveFileDialog. Here is my code, what am I doing wrong?
Thanks
Dim myStream As Stream
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
saveFileDialog1.AddExtension = True
saveFileDialog1.OverwritePrompt = True
saveFileDialog1.DefaultExt = ".txt"
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
If myStream.CanRead And myStream.CanWrite Then
Console.Write(TextBox1.Text)
End If
myStream.Close()
End If
End If
-
October 24th, 2002, 01:47 AM
#2
Is it something like this you had in mind?
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
saveFileDialog1.AddExtension = True
saveFileDialog1.OverwritePrompt = True
saveFileDialog1.DefaultExt = ".txt"
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim sw As New System.IO.StreamWriter(saveFileDialog1.OpenFile)
If Not (sw Is Nothing) Then
sw.Write(TextBox1.Text)
End If
sw.Close()
End If
/Leyan
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
|