Streams, Files, Readers and Writers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan Dickerson

    #1

    Streams, Files, Readers and Writers

    I evidently need to go back to remedial .Net class (I even 'Google'-ed this
    and didn't come up with much), as it must be so easy that even a neophyte
    could do it. So please help a neo-in-training!

    I just want to read a text file into a MemoryStream so as to use the stream
    for something else. I have instructions that work (I've tested them) for
    the 'something else,' but I'm having severe trials with the
    text-to-MemoryStream part. This is what I have (that's not working):

    Dim sAppDir As String = Replace(Applica tion.StartupPat h(), "bin",
    String.Empty)
    Dim fileIn As New StreamReader(sA ppDir & "Test1.xml" )
    Dim stream As New MemoryStream(fi leIn.ReadToEnd. Length)
    Dim writer As New StreamWriter(st ream)
    Dim fileOut As New StreamWriter(sA ppDir & "Test1_Results. txt")

    writer.Write(fi leIn.ReadToEnd. ToString)

    Thanx!

    --
    TFWBWY...A


  • YYZ

    #2
    Re: Streams, Files, Readers and Writers

    I honestly don't understand what you are trying to do...it looks like
    you get your memorystream ok, except that you don't DO anything with it
    -- I mean, you intialize it to hold all the text in the xml file, but
    then never do anything with it...

    Matt

    Comment

    • Bryan Dickerson

      #3
      Re: Streams, Files, Readers and Writers

      Well, I said that I had some example code for the 'do-something-with-it'
      part. But it's a mute point now, anyway, 'cause I figured it out and it's
      working. It's truly amazing what a decent night's sleep will do for your
      perspective...

      "YYZ" <matt.dawdy@gma il.com> wrote in message
      news:1139525082 .974754.241750@ z14g2000cwz.goo glegroups.com.. .[color=blue]
      >I honestly don't understand what you are trying to do...it looks like
      > you get your memorystream ok, except that you don't DO anything with it
      > -- I mean, you intialize it to hold all the text in the xml file, but
      > then never do anything with it...
      >
      > Matt
      >[/color]


      Comment

      Working...