I was trying to convert an Url to Stream but I am not sure whether I am right or wrong.
protected Stream GetStream(String gazouUrl) { Stream rtn = null; HttpWebRequest aRequest = (HttpWebRequest)WebRequest.Create(gazouUrl); HttpWebResponse aResponse = (HttpWebResponse)aRequest.GetResponse(); using (StreamReader sReader = new StreamReader(aResponse.GetResponseStream(), System.Text.Encoding.Default)) { rtn = sReader.BaseStream; } return rtn; }
Am I on the right track?
I ended up doing a smaller version and using WebClient
instead the old Http Request code:
private static Stream GetStreamFromUrl(string url) { byte[] imageData = null; using (var wc = new System.Net.WebClient()) imageData = wc.DownloadData(url); return new MemoryStream(imageData); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With