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.

Answer this question

StreamReader and StreamWriter

  • Rooster A.

    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


  • Patrick Ma

    no idea, working well here :)

    if you want to copy a file, just do:

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



  • Jakein2006

    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);



  • Ofir Epstein

    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


  • Harkernator

    thank you very much it works, im just really curious why when u used streamreader[writer] class to copy files the bytes were different
  • Roozbeh Sharafi

    no reason either :-P I guess everyone has their way of doing things. I was just going through your example and using that

  • Mark The Archer Evans

    can you show us some code please

    Moved to .NET Class library forum



  • StreamReader and StreamWriter