问题:基础连接已经关闭: 无法解析此远程名称。 用c#保存远程图片时提示"基础连接已经关闭: 无法解析此远程名称。 ",是不是端口被关闭的问题,要开什么端口呢?443吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 代码如下: //保存远程图片 public string Get_Img(string a_strUrl,int timeout,string filepath){ string errmsg; try{ HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(a_strUrl) ; myReq.Timeout = timeout; HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); Stream myStream = HttpWResp.GetResponseStream () ; Bitmap map = new Bitmap( myStream ); PictureBox picB = new PictureBox(); picB.Image = (Image)map; string path = filepath.Substring( 0,filepath.LastIndexOf( "\\" ) ); if (!Directory.Exists(path)){ //CreateDir( path ); } picB.Image.Save(filepath); errmsg="ok"; } catch(Exception exp){ string ss = exp.Message; //WriteLog( filepath.Substring(0,filepath.LastIndexOf("\\")) + "\\error.log",a_strUrl + "--" + ss + "\r\n"); errmsg=ss; } return errmsg; } 你这样写问题大大的b/s是用户发出请求,服务器返回信息。然后这个连接就会断掉,你只能发送个包含图片流的请求给服务器,服务器通过一系列操作后才能保存图像。就像httpfile组件一样 看到这样的情况,我很无奈 .net c# web 请问要怎么样设置才能把窗体设为对话框样式 关于滚动广告问题 500分请教模拟WEB文件自动上传功能,答对可以分几次给。 虚心求教`~~ 在.NET中如何判断大小写(CapsLock键)的状态? 如何用用c#访问word文档?? 通过ServiceProcess启动其他程序,并显示出来!+ 高分!!! 怎么把整个画面作为一张图片保存(很大有滚动条) 请教C#2003关机程序。。。谢谢啊 在RichTextBox中如何让滚动条使终位于最下方,即新输入的文本总是在最下面 急求解答,在线等待!!!
//保存远程图片
public string Get_Img(string a_strUrl,int timeout,string filepath){
string errmsg;
try{
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(a_strUrl) ;
myReq.Timeout = timeout;
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
Stream myStream = HttpWResp.GetResponseStream () ;
Bitmap map = new Bitmap( myStream );
PictureBox picB = new PictureBox();
picB.Image = (Image)map;
string path = filepath.Substring( 0,filepath.LastIndexOf( "\\" ) );
if (!Directory.Exists(path)){
//CreateDir( path );
}
picB.Image.Save(filepath);
errmsg="ok";
}
catch(Exception exp){
string ss = exp.Message;
//WriteLog( filepath.Substring(0,filepath.LastIndexOf("\\")) + "\\error.log",a_strUrl + "--" + ss + "\r\n");
errmsg=ss;
}
return errmsg;
}
b/s是用户发出请求,服务器返回信息。然后这个连接就会断掉,你只能发送个包含图片流的请求给服务器,服务器通过一系列操作后才能保存图像。就像httpfile组件一样