Results 1 to 2 of 2

Thread: save textbox to disk

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Posts
    76

    save textbox to disk

    Hi I am wondering how to save a textbox contents to disk?? Using the MSDN help I was able to come up with this code so far. I have a menu strip item labled "save as." when I click it the prompt to allow you to pick a location to save comes up and it will save a text file to the selected location but the .txt file is blank. How do I set this code so that it knows to save the contents of the textbox. Thanks!!

    Dim saveFileDialog1 As New SaveFileDialog()
    saveFileDialog1.Filter = "Text|*.txt"
    saveFileDialog1.Title = "Save File As"
    saveFileDialog1.ShowDialog()

    If saveFileDialog1.FileName <> "" Then
    Dim fs As System.IO.FileStream = CType _
    (saveFileDialog1.OpenFile(), System.IO.FileStream)
    fs.Close()
    End If

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: save textbox to disk

    I believe you need to use a StreamWriter to write it to a TextBox. MSDN should be able to provide an adequate example.

    Also, it's better if you place your code in Code or VBCode[/b] blocks.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width