1 接收数据流转成字符串,注意编码

byte[] recv= Request.BinaryRead(Request.TotalBytes);
string sourceByte = Encoding.UTF8.GetString(recv);

2 确认文件流在整个数据流的起止位置

比如:

从非标准的POST数据流中提取文件

 

//找到文件在字节流中的起止位置
int fileHeadLength = source.IndexOf("#!");
int fileFootLength = source.IndexOf("----", fileHeadLength);

3 从数据流中截取出来文件流,然后保存到指定路径

//保存文件
FileStream fss =new FileStream("path", FileMode.Create);
fss.Write(recv, fileHeadLength, fileFootLength-fileHeadLength);
fss.Close();

相关文章:

  • 2021-06-14
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-05-28
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2022-01-19
  • 2021-11-23
  • 2021-10-02
  • 2021-10-26
相关资源
相似解决方案