问题描述
我有一种方法可以使用 BinaryWriter 接收 Stream 以在其上写入.但是当我处理这个 BinaryWriter 时,它也会关闭流.我可以不处理它以便我可以打开我的流吗?
I have one method that receives a Stream to write on it using a BinaryWriter. But when I dispose this BinaryWriter it also closes the stream. Can I leave it undisposed so I can leave my stream open?
推荐答案
不要调用Dispose,改用Flush,安全.
Just do not call Dispose, use Flush instead, its safe.