none
System.Drawing.Image.FromStream(webStream) parameter is not valid in sharepoint RRS feed

  • Question

  • Hallo,

    I want to download a picture from SharePoint, I tested the code in console and that's good but at webpart I habe always error at

    image = System.Drawing.Image.FromStream (webstream) Parameter is not valid

     HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(imageUrl);
                    httpWebRequest.UseDefaultCredentials = true;
                    httpWebRequest.PreAuthenticate = true;
                    httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
                    httpWebRequest.AllowWriteStreamBuffering = true;
                    httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
                    httpWebRequest.Referer = "http://www.google.com/";
                    System.Net.WebResponse webResponse = httpWebRequest.GetResponse();
                    System.IO.Stream webStream = webResponse.GetResponseStream();

                    image = System.Drawing.Image.FromStream(webStream);
                    webResponse.Close();
                    webResponse.Close();


    • Edited by nacata Friday, August 30, 2013 6:50 AM
    Thursday, August 29, 2013 9:43 AM

Answers