一个WinForm应用程序要从服务器http共享中取图片然后画出来。
System.Drawing下的Image类,有个FromFile(string)的方法,其中可不可以是一个Url,如
“http://mysite/myfolder/mypic.jpg”这种形式?
谢谢!
System.Drawing下的Image类,有个FromFile(string)的方法,其中可不可以是一个Url,如
“http://mysite/myfolder/mypic.jpg”这种形式?
谢谢!
调试欢乐多
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);
strUrl = ""
WebClient wc = new WebClient();
wc.DownloadFile("http://lucky_elove.www1.dotnetplayground.com/Images/logo.gif","c:\\xx.gif");
byte[] myData = wc.DownloadData("http://www.microsoft.com/china/msdn/images/nhome/flash6.jpg");
System.IO.MemoryStream myStream = new System.IO.MemoryStream(myData);
this.pictureBox1.Image = Image.FromStream(myStream);
myStream.Close();