一个WinForm应用程序要从服务器http共享中取图片然后画出来。
System.Drawing下的Image类,有个FromFile(string)的方法,其中可不可以是一个Url,如
“http://mysite/myfolder/mypic.jpg”这种形式?
谢谢!

解决方案 »

  1.   

    用webclient获取一个二进制流,用Image的FromStream方法
      

  2.   

    string remoteUri = "http://www.contoso.com/library/homepage/images/";
    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);
      

  3.   

    http://sz.luohuedu.net/xml/ShowDetail.asp?id=CDBAB4E8-0938-4134-B86F-3B9E2C396E8Dstring strUrl;
    strUrl = ""
    WebClient wc = new WebClient();
    wc.DownloadFile("http://lucky_elove.www1.dotnetplayground.com/Images/logo.gif","c:\\xx.gif");
      

  4.   

    用webclient获取一个二进制流,用Image的FromStream方法
      

  5.   

    System.Net.WebClient wc = new System.Net.WebClient();
    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();