+92 332 4229 857 99ProjectIdeas@Gmail.com

SaveFileDialog (Vb.net)


SaveFileDialog is used to ask the user to select the location in your computer to save the file.

saveFile function returns the path of the file where it is saved.

sfd is an object of SaveFileDialog class which is used to call different functions contained in the SaveFileDialog class.

sfd.AddExtension function gets the value indicating whether the SaveFileDialog box will automatically adds the extension to a filename or not, in case if the user has not specified.

sfd.Filter function is used to get the file formats to be displayed in the SaveFileDialog box.

sfd.FileName returns the name of the file which is selected.

.ShowDialog() function shows the SaveFileDialog box.


1.     Public Function saveFile() As String
2.     Dim name As String = String.Empty
3.     Dim sfd As New SaveFileDialog
4.     sfd.AddExtension = True
5.     sfd.Filter = "|*.xls"
6.     With sfd
7.     If .ShowDialog = Windows.Forms.DialogResult.OK Then
8.     name = sfd.FileName
9.     End If
10.  End With
11.  Return name
12.  End Function