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
Re: StreamReader/StreamWriter
If you want all lines appended form source to destination, try this:
VB Code:
' Read in the whole file
Dim Source As New System.IO.StreamReader("C:\source.txt")
Dim temp As String
temp = Source.ReadToEnd()
Source.Close()
' Append to destination
Dim Destination As StreamWriter
Destination = System.IO.File.AppendText("C:\destination.txt")
Destination.WriteLine(temp)
Destination.Close()
Re: StreamReader/StreamWriter
How about posting some code?
Re: StreamReader/StreamWriter
Awesome. That's what I needed. Thanks very much.