Results 1 to 3 of 3

Thread: [RESOLVED] Memory stream to textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2010
    Posts
    197

    Resolved [RESOLVED] Memory stream to textbox

    Hi all, im trying to get a memory stream to a textbox, the memory stream is of a .txt or .ini file that is extracted from a archive to a memory stream.

    Heres what ive got so far:

    vb Code:
    1. Dim MSData As New System.IO.MemoryStream()
    2.  
    3.         Dim Infile As String = ComboBox10.SelectedValue 'The input archive
    4.         Dim passww As String = TextBox1.Text 'Archive password
    5.  
    6.         Using extr As New SevenZipExtractor(Infile, passww)
    7.             extr.ExtractFile("02.ini", MSData)
    8.         End Using
    9.  
    10.         Dim sr As StreamReader = New StreamReader(MSData)
    11.         Dim textSsS As String = sr.ReadToEnd()
    12.         ini02.Text = textSsS

    The problem is that ini02.text stays blank, so i know im missing somethign but not sure what, can anybody help

    Thanks


    EDIT: Sves bumping a solved thread, Thanks jmcilhinney, setting the possition fixed the problem.
    Last edited by DragonRose; Dec 19th, 2011 at 02:57 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Memory stream to textbox

    Try setting the Position of the MemoryStream to zero before reading.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Memory stream to textbox

    Also, don't forget to close your StreamReader and Dispose your MemoryStream. You should have Using blocks to create them so that it will be done implicitly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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