1 Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.IO;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceConsoleApplication49 {Ten class Program One { A Static voidMain (string[] args) - { - //1.txt Existence of the using(StreamReader Sreader =NewStreamReader (@"1.txt", Encoding.default)) - { - //2.txt does not exist, there is no new - using(StreamWriter Swriter =NewStreamWriter (@"2.txt")) + { - while(!Sreader.endofstream) + { A //if not to the end, I read a line to write a line at Swriter.writeline (Sreader.readline ()); - } - } - } -Console.WriteLine ("OK"); - Console.readkey (); in } - } to}
2 Read txt
3 Console Effects
4 Write txt (new)
But there is a strange thing, the size of the two files is different
Is it a matter of encoding format?
C # console Base StreamReader and StreamWriter read content from one txt to another txt