How do I use savefiledialog in vb.net

↘锁芯ラ 提交于 2019-12-18 09:03:23

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/15169531/how-do-i-use-savefiledialog-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!