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?
The SaveFileDialog control prompts the user to select a location for saving a file and allows the user to specify the name of the file to save data. The SaveFileDialog control class inherits from the abstract class FileDialog.
The SaveFileDialog component allows users to browse the file system and select files to be saved. The dialog box returns the path and name of the file the user has selected in the dialog box. However, you must write the code to actually write the files to disk.
To save your work, click File > Save All. The files are then saved in the Document folder on your computer, inside of a folder called Visual Studio 2019 (or whatever version you have).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With