What is wrong with the following code?
Stream inputstream = File.Open("e:\\read.txt", FileMode.Open);
Stream writestream = File.Open("e:\\write.txt", FileMode.OpenOrCreate);
do
{
writestream.WriteByte((byte)inputstream.ReadByte());
}
while (inputstream.ReadByte() != -1);
read.txt has “the quick brown fox jumped over the lazy dog.”
Whereas the write.txt file contains few contents skimmed “teqikbonfxjme vrtelz o.”
You’re only writing every other byte because you’re consuming one in the
whilecheck.