none
How to save a file using save file dialog in VB.Net 2003 RRS feed

  • Question

  • Hey, can anyone help me??? I want to save a text file using visual basic.net 2003 with save file dialog, but I don't know how to do that....
    Please help me......
    Thanx before
    Thursday, May 14, 2009 6:55 AM

Answers

  • Hi Friend,
      Using save file dialogue you will get the full file path of the file which you want to save.
    You will get ti from the FileName of the fileDialogue object. Please do check the DialogueResult object of the filedialoge object, to check it was a cancel or save button click! You can use the filename in a filestream or something to save the data.

            Dim dDilaoge As New SaveFileDialog
            dDilaoge.ShowDialog()
            Dim filename As String = dDilaoge.FileName
            Dim streamWriter As StreamWriter = File.CreateText(filename)
            streamWriter.Write("Your Text here")
            streamWriter.Flush()
    -- Thanks Ajith R [Remember to Mark as Answer if it is Helpful.]
    Thursday, May 14, 2009 7:05 AM
  • Hi Strike_freedom,

    I've reproduce Ajith's source code. It works.

    For your issue, here are some useful documents that show information on SaveFileDialog class and StreamWriter class.
    See:
    SaveFileDialog Class
    http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(VS.71).aspx
    StreamWriter Class
    http://msdn.microsoft.com/en-us/library/system.io.streamwriter(VS.71).aspx

    If you have any further concern, please feel free to let me know.

    Thanks
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 15, 2009 9:02 AM

All replies