dimanche 5 août 2018

ByteArray is giving broken image

I am converting SharePoint image to Byte[] by using following code:

        var webClient = new WebClient();
        string imageUrl = retriveResponse.AbsoluteUrl.ToString() + "/test.jpg";
        var webclient = new WebClient();
        webclient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
        //webclient.Headers.Add(HttpRequestHeader.Accept, "application/octet-stream");
        //webclient.Headers.Add("binaryStringRequestBody", "true");
        webclient.Credentials = new NetworkCredential(WebConfigurationManager.AppSettings["Username"], 
        WebConfigurationManager.AppSettings["Password"]);
        imageBytes = webclient.DownloadData(imageUrl);
        webclient.Dispose();

When I check the ImageBytes on this, it shows broken image. Please let me know where I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire