StreamReader and StreamWriter

I have problems using StreamReader and StreamWriter. everytime i copied a textfile from StreamReader to StreamWriter. the files bytes are in different size. please need help on this matter.
[189 byte] By [QuinceArj] at [2007-12-22]
# 1

can you show us some code please?

Moved to .NET Class library forum

ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2

Dim sstream As New StreamReader("c:\EULA.txt")

Dim sstream2 As New StreamWriter("e:\EULA.txt", FileMode.Create)

Do Until sstream.Peek = -1

sstream2.WriteLine(sstream.ReadLine)

Loop

sstream.Close()

sstream.Close()

more info:

the destination file E:\eula.txt has more bytes (file size ) than the source (c:\eula.txt) please i need help

QuinceArj at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3

if these are textfile, try this:



Dim theReader as new StreamReader("file.txt")
Dim theWriter as new StreamWriter("copyfile.txt")
theWriter.Write(theReader.ReadToEnd())
theWriter.Close()
theReader.Close()

or if you want to copy a file, just use:

System.IO.File.Copy(source, dest);

ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 4

ok i tried but the file is different bytes again

the source file is 38060 bytes

the destination 38788 bytes , how could the destination file had a different bytes copied?

QuinceArj at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 5

no idea, working well here :)

if you want to copy a file, just do:

System.IO.File.Copy(Source, Destination);

ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 6
thank you very much it works, im just really curious why when u used streamreader[writer] class to copy files the bytes were different?
QuinceArj at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 7
no reason either :-P I guess everyone has their way of doing things. I was just going through your example and using that
ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified