static public byte[] GetUrl(string url)
{ byte[] buf;
try
{
WebProxy myProxy = new WebProxy();
IWebRequestCreate req = (IWebRequestCreate)WebRequest.Create(url);
//WebRequest reqw = WebRequest.Create(req);
WebResponse response = req.GetResponse();
stream = response.GetResponseStream();
using (BinaryReader br = new BinaryReader(stream))
{
int len = (int)(response.ContentLength);
buf = br.ReadBytes(len);
br.Close();
}
stream.Close();
response.Close();
}
catch (Exception exp)
{
buf = null;
}
return (buf); }
此处url ="数据:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAC + CAIAAACu1eR2A"像那样。如何传递url IWebRequestCreate并获得响应?请让你知道。它对我的项目非常有用。
这里的网址是
数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAC + CAIAAACu1eR2A"
不被接受。因此,如果我要将数据替换为http或https,则会引发错误,无法识别网址。怎么办?