Results 1 to 4 of 4

Thread: StreamReader/StreamWriter

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    20

    StreamReader/StreamWriter

    Hi,
    I was wondering if I could get some help with IO.StreamReader and IO.StreamWriter. I have looked at a few examples and tried a few different ways but cannot seem to get these to work.
    I am trying to write/append from one file to another. Source to Master.
    Here is some info for the sake of an example.

    Locations:
    C:\ScanData\source.txt
    C:\ScanData\Master.txt

    Data:
    Data is scanned into a text file, so each scan is placed on a new line. Depending on time of day, there could be a few to very many lines on the source.txt that I need transferred over to Master.txt.(once transfer takes place..source is deleted to make room for another source.txt later on)

    This seems to be where my problem is..getting all the lines from source to master..the code runs through without error..but nothing happens as far as writing.

    Any help would be appreciated.

    Thanks

  2. #2
    Hyperactive Member jonwondering's Avatar
    Join Date
    May 2005
    Posts
    311

    Re: StreamReader/StreamWriter

    If you want all lines appended form source to destination, try this:

    VB Code:
    1. ' Read in the whole file
    2. Dim Source As New System.IO.StreamReader("C:\source.txt")
    3. Dim temp As String
    4. temp = Source.ReadToEnd()
    5. Source.Close()
    6.  
    7. ' Append to destination
    8. Dim Destination As StreamWriter
    9. Destination = System.IO.File.AppendText("C:\destination.txt")
    10. Destination.WriteLine(temp)
    11. Destination.Close()

  3. #3
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: StreamReader/StreamWriter

    How about posting some code?
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    20

    Re: StreamReader/StreamWriter

    Awesome. That's what I needed. Thanks very much.

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