生成圖片的URL假設(shè)是這樣:http://localhost/administrator/qrcode.aspx?pid=78qrcode.aspx.cs的生成圖片的部分代碼:Imageimage=newBitmap(200,200);Graphicsg=Graphics.FromImage(image);try{stringurl="http://localhost";DotNetBarcodebc=newDotNetBarcode();bc.Type=DotNetBarcode.Types.QRCode;bc.PrintCheckDigitChar=true;bc.WriteBar(url,0,0,210,210,g);System.IO.MemoryStreamms=newSystem.IO.MemoryStream();image.Save(ms,System.Drawing.Imaging.ImageFormat.Png);Response.ClearContent();Response.ContentType="image/Png";Response.BinaryWrite(ms.ToArray());ms.Dispose();}finally{g.Dispose();image.Dispose();}現(xiàn)在如果我要輸入http://localhost/administrator/qrcode.aspx?pid=78&download=true就下載圖片到本地要怎么做?找過(guò)一些資料,WebClient.DownloadFile方法不知道怎么用。滿足參數(shù)download=true的時(shí)候使用Image.Save(stringfilename,ImageFormatformat);似乎不起作用,不知道什么原因。
C#如何通過(guò)URL下載圖片?
陪伴而非守候
2019-04-13 08:45:19