【发布时间】:2021-10-06 07:37:56
【问题描述】:
我正在尝试下载图像(jpg、jpeg 和 png)。但是当大小超过 200,000 字节时,我会得到一张黑白图片。
我的代码:
byte[] fileBytes;
try
{
path = url + path;
fileBytes = (new WebClient()).DownloadData(path);
}
catch
{
path = urlNoimagefound;
fileBytes = (new WebClient()).DownloadData(path);
}
...
// and then I add byte in rdlc
由于字节数组的大小,我想我得到一张黑白图片。
如何解决?
谢谢。
【问题讨论】:
-
您是否遇到了某种异常?
-
对不起,你能解释更多吗?什么是异常?
-
对不起,我的错,我有路径例外。我正在编辑这篇文章。
-
如果它到达
catch方法,那么你应该让它通过catch (Exception ex)产生异常,然后一旦你进入catch部分,ex就会有错误数据。
标签: c#