❔ 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
Don't use
WebClient
what would i use?
HttpClient
To clarify: HttpClient is the modern webclient and works better for fetching/sending data.
What is VersionText.Text?
Probably a WinForms label or something
Sure, but what is the value?
the value is 0.1.3
same goes for the github
im just trying to test if the messagebox pops up but it doesnt.
Check to see if the string from github has a linefeed or something at the end
it didnt.
huh
Don't know if that's just chrome view-source UI thing, but check it with the debugger
just in case
yeah in github it does show that but i cant make it one.
Try trimming the whitespace first before comparing
Another option is parse both into a Version: https://learn.microsoft.com/en-us/dotnet/api/system.version.parse?view=net-6.0
Version.Parse Method (System)
Converts the specified read-only span of characters that represents a version number to an equivalent Version object.
Trimming worked!
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
Alright, something new i learned 🙂
I still recommending parsing them into a Version, it will make the comparison easier
No need to roll your own
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.