[Solved] Using FileStream classes to copy files, why does output not match input?


I don’t know what you’re doing, but why don’t you try this, it’s likely that reading and writing through a FileStream might not be encoding agnostic, so stick with a stream and just pass bytes along:

using (Stream inStream = File.Open(inFilePath, FileMode.Open))
{
    using (Stream outStream = File.Create(outFilePath))
    {
        while (inStream.Position < inStream.Length)
        {
            outStream.WriteByte((byte)inStream.ReadByte());
        }
    }
}

3

solved Using FileStream classes to copy files, why does output not match input?