保存图片 向从网上下载图片,知道图片的地址。应该怎么做,涉及到哪些知识。谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像是Server.MapPath吧不是很清楚哦 比如:private void button1_Click(object sender, EventArgs e){ WebClient wc = new WebClient(); byte[] bts = wc.DownloadData("http://community.csdn.net/expert/images/rank/star4.gif"); MemoryStream ms = new MemoryStream(bts); Image img = Image.FromStream(ms); img.Save(@"D:\start.gif");} 我用的是web,Image方法不行。怎么保存成图片? public string Get_Img(string a_strUrl, int timeout, string filepath) { //参数a_strUrl图片的url,timeout设置过期时间,filepath设置存放的物理文件夹路径 if ( string.Equals(a_strUrl,"")) { return "没有图片"; } try { folderclass folder = new folderclass(); HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(a_strUrl); myReq.Timeout = timeout; HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); Stream myStream = HttpWResp.GetResponseStream(); Bitmap map = new Bitmap(myStream); ImageButton aa = new ImageButton(); long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL)|(int)(tick >>32)); string filename = "pic" + DateTime.Now.ToString().Replace(":", "-") + ran.Next(100, 999).ToString() + ".jpg"; filepath = filepath + folder.getfolder(Server.MapPath("sizhaquimage")) + filename; map.Save(filepath); return "sizhaquimage/" + folder.getfolder(Server.MapPath("sizhaquimage")) + filename; } catch (Exception exp) { string ss = exp.Message; return "没有图片"; } } 类型"System.Int64"的对象无法转换为类型"System.String" 一个问题 能不能在页面实现大转盘抽奖的效果?不用Flash! vs2008中如何使用ASP.NET AJAX? 求一牛牛的正则表达式++++++++++++++++ 页面第二次刷新和第四次刷新有什么区别呢?问题解决立即散分! 如何在datagrid里使用<input type="file" runat="server"> 動態控件設置值的問題 请教一个问题! 关于sql语句的单引号问题 路径 GridView问题,请教高手
不是很清楚哦
{
WebClient wc = new WebClient();
byte[] bts = wc.DownloadData("http://community.csdn.net/expert/images/rank/star4.gif");
MemoryStream ms = new MemoryStream(bts);
Image img = Image.FromStream(ms);
img.Save(@"D:\start.gif");
}
{
//参数a_strUrl图片的url,timeout设置过期时间,filepath设置存放的物理文件夹路径
if ( string.Equals(a_strUrl,""))
{
return "没有图片";
}
try
{
folderclass folder = new folderclass();
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(a_strUrl); myReq.Timeout = timeout; HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); Stream myStream = HttpWResp.GetResponseStream(); Bitmap map = new Bitmap(myStream);
ImageButton aa = new ImageButton();
long tick = DateTime.Now.Ticks;
Random ran = new Random((int)(tick & 0xffffffffL)|(int)(tick >>32));
string filename = "pic" + DateTime.Now.ToString().Replace(":", "-") + ran.Next(100, 999).ToString() + ".jpg";
filepath = filepath + folder.getfolder(Server.MapPath("sizhaquimage")) + filename;
map.Save(filepath);
return "sizhaquimage/" + folder.getfolder(Server.MapPath("sizhaquimage")) + filename; } catch (Exception exp)
{ string ss = exp.Message;
return "没有图片";
} }