我想将字节数组附加到现有文件中。它必须位于文件的末尾。我已经可以设法在文件的开头写入。(感谢 stackoverflow ;))。
代码:
public bool ByteArrayToFile(string _FileName, byte[] _ByteArray)
{
try
{
// Open file for reading
System.IO.FileStream _FileStream =
new System.IO.FileStream(_FileName, System.IO.FileMode.Create,
System.IO.FileAccess.Write);
// Writes a block of bytes to this stream using data from
// a byte array.
_FileStream.Write(_ByteArray, 0, _ByteArray.Length);
// close file stream
_FileStream.Close();
return true;
}
catch (Exception _Exception)
{
// Error
Console.WriteLine("Exception caught in process: {0}",
_Exception.ToString());
}
// error occured, return false
return false;
Run Code Online (Sandbox Code Playgroud)
}
从这里得到的:
但我需要它在文件末尾
提前致谢。
找到了解决方案: …