.NET Framework 在框架的多个领域里使用了流模型。流是允许你用相似的方式(作为顺序字节流)对待不同数据源的一种抽象。所有 .NET 流类从 System.IO.Stream 类继承。

       流可以代表内存缓冲器中的数据、从网络连接获得的数据、从文件获得的或要写入文件的数据。

       下面这段代码演示了如何创建一个新文件并用 FileStream 写入一个字节数组:

null;
try
{
    fileStream = new FileStream(filename, FileMode.Create);
    fileStream.Write(bytes, 0, bytes.Length - 1);
}
finally
{
    if (fileStream!=null)
    {
        fileStream.Close();
    }        
}

相关文章:

  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-11-04
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2022-02-15
  • 2022-12-23
  • 2022-01-24
  • 2021-06-17
  • 2021-08-10
  • 2021-07-20
相关资源
相似解决方案