Hi Developers,
In my project when i am try to download image from a online path i got the following error.
"The given path's format is not supported."
I have using the following code.
if (objRequest.ImageName != "")
{
string ApplicationFormPath = System.Configuration.ConfigurationManager.AppSettings["CustomerProofDetailsSourceFile"];
string IdProofImage = "https://yoururl.com/logo.png";
string image = DownloadImageFromUrl(IdProofImage);
string imgBase64String = GetBase64StringForImage(IdProofImage);
objRequest.ImageData = imgBase64String;
}
DownloadImageFromUrl Method:
public string DownloadImageFromUrl(string imageUrl)
{
string imageString = string.Empty;
System.Drawing.Image image = null;
try
{
imageUrl = "https://yoururl.com/logo.png";
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(imageUrl);
webRequest.AllowWriteStreamBuffering = true;
webRequest.Timeout = 30000;
System.Net.WebResponse webResponse = webRequest.GetResponse();
System.IO.Stream stream = webResponse.GetResponseStream();
image = System.Drawing.Image.FromStream(stream);
//imageString = Convert.ToBase64String(image);
string imgBase64String = GetBase64StringForImage(image.ToString());
webResponse.Close();
}
catch (Exception ex)
{
return imageString;
}
return imageString;
}
I am trying with google If anyone know how to do this task kindly suggest to complete this task
Thanking You
Paul.S