首页 > 解决方案 > 如果您需要在从同一流写入数据后读取它的数据,是否需要将 Flush 调用到 FileStream?

问题描述

using Stream someOtherData = GetMeSomeData();
using FileStream fs = File.Create("Hello-world!");
someOtherData.CopyTo(fs);
fs.Flush(); // Is this needed?
fs.Position = 0;
ReadDataInStream(fs); // Reads the data in the stream by using Stream.Read().

标签: c#.net.net-coreiofilestream

解决方案


推荐阅读