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;
If you look at documentation for WebRequest.Create
you will see that return type of the method is WebRequest
, so you need to return it in your code:
System.Net.WebRequest request = System.Net.HttpWebRequest.Create("http://www.google.com");
System.Net.WebResponse response = request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
string newestversion = sr.ReadToEnd();