I have a question/I need help, I'm trying to make a "updater" for my C# program, and I'm always getting this error
Cannot implicitly convert type 'System.Net.WebRequest' to 'System.Net.HttpWebRequest'. An explicit conversion exists (are you missing a cast?)
I was trying to make this "updater" as similar as possible to my .vb "updater", if anyone could help me solve this error I would be very thankful and happy, or if someone can send me a link to read about C# etc. I would also be very thankful, I'm very new to C# or the C family as well
System.Net.HttpWebRequest request = System.Net.HttpWebRequest.Create("link");
System.Net.HttpWebResponse response = request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
string newestversion = sr.ReadToEnd();
string currentversion = Application.ProductVersion;
You have to use the System.Net.WebRequest.Create method and cast the returned instance to System.Net.HttpWebRequest:
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");
See: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(v=vs.110).aspx#Anchor_7
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