我的代码是:
string sMD5Hash = sb.ToString();
using(Stream stream = new FileStream(sFile, FileMode.OpenOrCreate))
{
stream.Seek(5, SeekOrigin.Begin);
stream.Write(Encoding.ASCII.GetBytes(sMD5Hash), 0, sMD5Hash.Length);
}
我想要做的是,寻求5并开始在那里写我的字符串。不经常写,因为它会推动下一个字节前进。但相反,我想覆盖字节。我怎么能这样做?
答案 0 :(得分:1)
制作FileStream FileMode.OpenOrCreate
和FileAccess.ReadWrite
using (Stream stream = new FileStream(sFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
stream.Seek(5, SeekOrigin.Begin);
stream.Write(Encoding.ASCII.GetBytes(sMD5Hash), 0, sMD5Hash.Length);
}