[windows Store app] stream does not support seek opeartions solve solution

本文讨论了在使用HttpWebResponse的GetResponseStream方法时遇到的流不支持回溯的问题,并提供了将数据传输到MemoryStream的方法以解决此问题。通过使用await方法和MemoryStream,不仅解决了回溯问题,还避免了数据丢失。同时,解释了在遇到类似问题时如何查阅MSDN等资源来寻找解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

stream does not support seek operations 

 

When  I use HttpWebResponse.GetResponseStream();  the stream does't support seek

 

so  try to transfers to MemoryStream

1 using (Stream Result = request.HttpWebResponse.GetResponseStream())
2 {
3     MemoryStream streamResult = new MemoryStream();
4     byte[] buf = new byte[1024 * 8];
5     int count = await Result.ReadAsync(buf, 0, 1024 * 8);
6     streamResult.Write(buf, 0, count);
7 }

 

this can work well, but  firstly I did't use await method the stream also lost bytes ,I user Result.Read() Method;

I worry so much,But the next day, I checked the website MSDN ,  I see Async  the keywords, oh  I feel this will be help ,  It solve the problem . 

 

hope this help to your

 

转载于:https://www.cnblogs.com/liumianweifeng/p/3364746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值