C
C#16mo ago
Jin

❔ Downloading string from webclient isnt responding properly to my if statement.

So im trying to make a version check by grabbing the data from a raw github link, it gets the data but my if statement isnt detecting it properly. Its most likely the downloaded string is breaking or something but i have no clue.
23 Replies
Thinker
Thinker16mo ago
Don't use WebClient
Jin
Jin16mo ago
what would i use?
Thinker
Thinker16mo ago
HttpClient
FusedQyou
FusedQyou16mo ago
To clarify: HttpClient is the modern webclient and works better for fetching/sending data.
Thinker
Thinker16mo ago
HttpClient client = new();
var response = await client.GetAsync(url);
var download = await response.Content.ReadAsStringAsync();
HttpClient client = new();
var response = await client.GetAsync(url);
var download = await response.Content.ReadAsStringAsync();
Axiss
Axiss16mo ago
What is VersionText.Text?
Thinker
Thinker16mo ago
Probably a WinForms label or something
Axiss
Axiss16mo ago
Sure, but what is the value?
Jin
Jin16mo ago
the value is 0.1.3 same goes for the github im just trying to test if the messagebox pops up but it doesnt.
Axiss
Axiss16mo ago
Check to see if the string from github has a linefeed or something at the end
Jin
Jin16mo ago
Jin
Jin16mo ago
it didnt.
Axiss
Axiss16mo ago
Jin
Jin16mo ago
huh
Axiss
Axiss16mo ago
Don't know if that's just chrome view-source UI thing, but check it with the debugger just in case
Jin
Jin16mo ago
yeah in github it does show that but i cant make it one.
Thinker
Thinker16mo ago
Try trimming the whitespace first before comparing
Axiss
Axiss16mo ago
Version.Parse Method (System)
Converts the specified read-only span of characters that represents a version number to an equivalent Version object.
Jin
Jin16mo ago
Trimming worked!
Axiss
Axiss16mo ago
Comparing raw strings it's always a good idea to trim them. Very easy to accidently get non-visible whitespace in there screwing with you
Jin
Jin16mo ago
Alright, something new i learned 🙂
Axiss
Axiss16mo ago
I still recommending parsing them into a Version, it will make the comparison easier No need to roll your own
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ how to make an API callI have tried looking up tutorials but they ended up making me more confused. I want to take a string❔ Best approach to share several properties application-wide in a WinUI3 project?Hi, I am looking for the preferred way, following the best practices for a small scale desktop appli❔ Blazor communicate with WebAPI on localhost serverHello, I want to start making a staging environment for my application, I got a WebAPI ready and wor❔ Get Pixels cords from Image by their colorHey, I'm writing a game and I need to get the pixels cords by their colors from an Image, I tried us❔ Storing & retrieving face encodings to compareWhat's the best way to store face encodings (an array of size 128 and type float64) in a database an❔ New to C# and am trying to make a Minesweeper console appI am having trouble with my "UpdateBoard" method and I can not seem to figure out what the problem i❔ System.Data.OleDb.OleDbException: 'Could not find installable ISAM.' errorHi anyone can help me? i start the test and i got System.Data.OleDb.OleDbException: 'Could not find ❔ Accounting for Daylight Savings Time skips at runtimeMy Discord bot I am developing has a reminder system which utilizes <https://github.com/robbell/nChr✅ I need to put an invalid choice in my programI need to make the program repeat if they did not input a valid response of yes or no❔ My project runs successfully but doesn't load ( works fine when I run it without debugging )my project was working fine but suddenly whenever I run it it keeps loading without showing anything