如何在 vb.net 中使用 savefiledialog
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15169531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I use savefiledialog in vb.net
提问by user2122062
I have a program called TextEditPro and I just started it, I'm running into a problem.
我有一个名为 TextEditPro 的程序,我刚启动它,遇到了一个问题。
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!
当我有点击另存为的代码时...我不知道如何使用 savefiledialog 所以当你点击另存为时它会弹出!
Any help?
有什么帮助吗?
回答by Ken White
Learn to use MSDN- the documentationfor SaveFileDialog
has an example
了解如何使用MSDN-该文档为SaveFileDialog
有一个例子
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