How do I use savefiledialog in vb.net
Asked Answered
E

1

6

I have a program called TextEditPro and I just started it, I'm running into a problem.

When I had the code for clicking Save As... I don't know how to use the savefiledialog so when you click Save As it will pop up!

Any help?

Etherege answered 2/3, 2013 at 1:15 Comment(0)
R
11

Learn to use MSDN - the documentation for SaveFileDialog has an example

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim myStream As Stream
    Dim saveFileDialog1 As New SaveFileDialog()

    saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
    saveFileDialog1.FilterIndex = 2
    saveFileDialog1.RestoreDirectory = True 

    If saveFileDialog1.ShowDialog() = DialogResult.OK Then
        myStream = saveFileDialog1.OpenFile()
        If (myStream IsNot Nothing) Then 
            ' Code to write the stream goes here.
            myStream.Close()
        End If 
    End If 
End Sub
Rima answered 2/3, 2013 at 1:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.