public void StreamToFile(Stream stream,string fileName)

{

// 把 Stream 转换成 byte[]

byte[] bytes = new byte[stream.Length];

stream.Read(bytes, 0, bytes.Length);

// 设置当前流的位置为流的开始

stream.Seek(0, SeekOrigin.Begin);

// 把 byte[] 写入文件

FileStream fs = new FileStream(fileName, FileMode.Create);

BinaryWriter bw = new BinaryWriter(fs);

bw.Write(bytes);

bw.Close();

fs.Close();

}

相关文章:

  • 2021-05-20
  • 2022-12-23
  • 2021-12-06
  • 2021-06-18
  • 2021-08-02
  • 2021-12-04
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案