gpt4 book ai didi

c# - 改变输出流的位置

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:40 24 4
gpt4 key购买 nike

我需要更改写入输出流的 header 从末尾到开头的位置,有没有更好的方法可以做到这一点

outputStream.Write(header, 0, header.Length);
outputStream.Position = outputStream.Position - header.legnth;

最佳答案

 outputStream.Write(header, 0, header.Length);

将stream的位置移动到header的末尾,

outputStream.Seek(header.Length, SeekOrigin.End);

上面的Seek会将流的位置移动到开头。假设header长度为2字节。你已经写了 2 个字节,然后 Seek 将位置向后移动 2 个字节。

关于c# - 改变输出流的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25518941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com