将字节数组转换为流时,ReadTimeout引发异常 [英] ReadTimeout threw an exception when converting byte array to Stream

查看:123
本文介绍了将字节数组转换为流时,ReadTimeout引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误

ReadTimeout = '((System.IO.Stream)(ms)).ReadTimeout' threw an exception of type 'System.InvalidOperationException'.

我的代码是.

byte[] imageBytes = Convert.FromBase64String(img);
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);     //Problem generates here//

谢谢..

推荐答案

您可以使用 WriteTimeout 属性,仅在流支持超时的情况下.您可以通过 CanTimeout 属性进行检查.如果CanTimeout属性返回false,则所有对这些属性的访问应该引发InvalidOperationException.

You can use the ReadTimeout/WriteTimeout properties only if the stream support timing out. You can check this via the CanTimeout property. If the CanTimeout property returns false all access to these properties should raise an InvalidOperationException.

这篇关于将字节数组转换为流时,ReadTimeout引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆