How do I read a raw byte array from any file, and write that byte array back into a new file?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
(edit: note that the question changed; it didn't mention
byte[]
initially; see revision 1)Well,
File.Copy
leaps to mind; but otherwise this sounds like aStream
scenario:Adding an up to date answer,
you can optionally specify the buffer size
or you could perform the operation on another thread,
which would be useful when the main thread has to do other work, like with WPF and Windows Store apps.
Do you know about TextReader and TextWriter, and their descendents StreamReader and StreamWriter? I think these will solve your problem because they handle encodings, BinaryReader does not know about encodings or even text, it is only concerned with bytes.
How to read text from a file
How to write text to a file
This is an excellent intro to file IO and encodings.