I get the 401 message when I try to get an image from a local SharePoint site. Tried a number of credentials settings but they all return the same 401 error.
var SharePointURL = "http://SharePointServer/Site/ImageFolder/image1.jpg";
System.Net.WebRequest req = System.Net.WebRequest.Create(SharePointURL);
req.Credentials = System.Net.CredentialCache.DefaultCredentials;
req.UseDefaultCredentials = true;
System.Net.WebResponse response = req.GetResponse();
Stream stream = response.GetResponseStream();
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
stream.Close();
Any help would be appreciated.