C
C#16mo ago
Lemur2591

❔ So I've created a downloader, how do I link a progress bar to it? Winform, .NET framework

here's my code (website down rn):
private void button1_Click(object sender, EventArgs e)
{
var client = new WebClient();


try
{
client.DownloadFile("http://moonshroud.net/patchingtest.zip", @"patchtest.zip");
string zipPath = @".\patchtest.zip";
string extractPath = @".\Wrath of the Lich King";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\Wrath of the Lich King\Data\enUS\realmlist.wtf");


client.DownloadFile("http://moonshroud.net/World-of-Warcraft-3.3.5a.12340-enUS%20PATCH.zip", @"patch.zip");
zipPath = @".\patch.zip";
extractPath = @".\Wrath of the Lich King";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\patchtest.zip");
File.Delete(@".\patch.zip");
}

catch {}

}
private void button1_Click(object sender, EventArgs e)
{
var client = new WebClient();


try
{
client.DownloadFile("http://moonshroud.net/patchingtest.zip", @"patchtest.zip");
string zipPath = @".\patchtest.zip";
string extractPath = @".\Wrath of the Lich King";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\Wrath of the Lich King\Data\enUS\realmlist.wtf");


client.DownloadFile("http://moonshroud.net/World-of-Warcraft-3.3.5a.12340-enUS%20PATCH.zip", @"patch.zip");
zipPath = @".\patch.zip";
extractPath = @".\Wrath of the Lich King";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\patchtest.zip");
File.Delete(@".\patch.zip");
}

catch {}

}
if I understand correctly, it doesn't really have a way to keep track of this. It's just not there then suddenly it is. how would I go about linking this to my progress bar?
64 Replies
ero
ero16mo ago
why make a program that downloads something a whole winforms app? why not just a simple console?
Lemur2591
Lemur259116mo ago
aren't consoles not really user friendly?
ero
ero16mo ago
they can be made to be $spectre
MODiX
MODiX16mo ago
Spectre.Console is a .NET library that allows for easy creation of console UIs, text formatting in the console, and command-line argument parsing. https://spectreconsole.net/
Spectre.Console - Welcome!
Spectre.Console is a .NET library that makes it easier to create beautiful console applications.
ero
ero16mo ago
spectre also has progress bars a console app will also be cross platform, unlike a winforms app
Lemur2591
Lemur259116mo ago
this does look very cool, but it seems like it'd be a bit too late to switch now, I already have the downloader working (you wouldn't believe how long that took, I'm code illiterate and a slow learner)
ero
ero16mo ago
are you under some time constraint?
Lemur2591
Lemur259116mo ago
no, but I think I would rather have it done in the next few hours, otherwise I don't feel productive
ero
ero16mo ago
i'd say learning some new concepts is being pretty damn productive
Lemur2591
Lemur259116mo ago
well yeah but that's not the new concept I came here to learn I wanted to learn the concept of adding a progress bar to my application
ero
ero16mo ago
i don't use webclient, so no idea if it has any of the capabilities httpclient does i can recommend learning the concept of not using out of date frameworks and types ;) jesting of course
Lemur2591
Lemur259116mo ago
you know what, I'll entertain the idea. do you think it'll be easier to achieve what I want using console?
ero
ero16mo ago
mhh... no! i assume you're more of a beginner in c#?
Lemur2591
Lemur259116mo ago
THEN WHY SUGGEST IT? 😭
ero
ero16mo ago
i mean if you weren't a beginner then it would undoubtedly be easier you don't have a UI to deal with spectre takes care of most of the logic you're able to basically write your entire code in 1 single file and it looks good too but spectre.console introduces a lot of concepts that might be very new to you and it requires reading up a bit i think its API is pretty intuitive for the progress bar... just copy the code from somewhere else, honestly :p long as you try to understand what's happening, that's fine (yes spectre has progress bars)
Lemur2591
Lemur259116mo ago
do you have an example of the code I should be copying? because I did spend a few hours before asking here, this wasn't my first idea
ero
ero16mo ago
oh i only have code for spectre like i said, i don't use webclient (nor winforms, but that's another story) so i don't know its capabilities
Lemur2591
Lemur259116mo ago
okay if you can show me spectre code for a progress bar and download I will switch over, but otherwise it's just a massive step backwards hold on I'll just share with you my simple vision for what this'd be as a terminal program, you tell me if it's got what I'm after
[T]he Burning Crusade
[W]rath of the Lich King
[T]he Burning Crusade
[W]rath of the Lich King
if you press [V] for instance
[P]lay Now (Not Installed)
[M]anage addons
[R]eset Config

[I]nstall Vanilla
[B]ack to Home
[P]lay Now (Not Installed)
[M]anage addons
[R]eset Config

[I]nstall Vanilla
[B]ack to Home
if you press [I] it'd change to
Download Progress
[######===============] 25%

[P]ause Download
[C]ancel Download
Download Progress
[######===============] 25%

[P]ause Download
[C]ancel Download
would this be possible using spectre?
ero
ero16mo ago
i'm not sure about the pause/cancel during the download everything else is easy
Lemur2591
Lemur259116mo ago
alright that kinda sucks but I mean, if everything else can be done that's more than I have, and that makes interface design a lot simpler. about aesthetics though, I'm sure I can choose fun wacky colors for the text, but can I change font size? my vision is weak and I don't want tiny text that's hard to read
ero
ero16mo ago
a console app chooses whatever design you have for your preferred terminal
Lemur2591
Lemur259116mo ago
so you're telling me that can't be configured without each user specifically configuring it for their whole terminal? how about auto updaters? I've got an autoupdate application written for my winform app terminal programs can do that?
ero
ero16mo ago
depends on how you implemented it i guess?
Lemur2591
Lemur259116mo ago
hey doesn't this seem like a direct download in every possible category to you?
ero
ero16mo ago
hm?
Lemur2591
Lemur259116mo ago
like, if you show me that it's really easy to code in, and actually it's really intuitive to work in, and it's super easy to format in etc then yeah I'm on board, but all you've said really is "well yeah but it can do atleast half or maybe a third of what you want, but that thing you want to do? that's easy" and I'm skeptical to rewrite everything I've done just because of that claim, because you've not really shown me that it even is easier to make a progress bar in spectre. Winforms is as far as I'm aware designed to be easy, and the user interface has never held me back, it's only been helpful. Can you please show an example of a progress bar on a download in spectre, and show me an example of page navigation in spectre?
ero
ero16mo ago
ero
ero16mo ago
obviously there's many many ways to handle the prompts, i've sorta hard coded the branches here what i usually do is have a Steps or Stages folder where i split up the logic https://github.com/just-ero/Unity-PDB-Downloader https://github.com/just-ero/asl-utils
Lemur2591
Lemur259116mo ago
okay you seem knowledgeable, how would I even create a window for this? like, do I just paste it into a text file with a certain extension and save it? will it need dependencies to run? if I distribute this, will it require the user install anything other than the program?
ero
ero16mo ago
what do you mean "create a window for this"? "paste it into a text file"? what have you been coding in up to now?
Lemur2591
Lemur259116mo ago
like, I use visual studio, and I use winforms in visual studio so like, what do I do with this?
ero
ero16mo ago
it's a console app you create a new console app project, install the spectre.console nuget, and you're done
Lemur2591
Lemur259116mo ago
I just open the console app preset on vs? gotcha
ero
ero16mo ago
$newproject
MODiX
MODiX16mo ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
ero
ero16mo ago
try to use .net 7 install it if you don't have it yet
Lemur2591
Lemur259116mo ago
I would but I've got certain limitations
ero
ero16mo ago
hm?
Lemur2591
Lemur259116mo ago
I have to use 4.0 only
ero
ero16mo ago
why?
Lemur2591
Lemur259116mo ago
the game I'm working on was made in XNA in 2013
ero
ero16mo ago
is wow not on linux or mac?
Lemur2591
Lemur259116mo ago
no no that's something different I'm talking about charlier murder, I want my experience to translate though
ero
ero16mo ago
i still don't really see how that has to do with the framework this installer is made in though
Lemur2591
Lemur259116mo ago
it doesn't I want my experience to translate though
ero
ero16mo ago
i don't understand
Lemur2591
Lemur259116mo ago
I don't want to spend all year coding in .net 7, go to work on the game and be like "WOW THIS IS ALL VERY FOREIGN TO ME I SURE WISH I KNEW A SINGLE THING ABOUT .NET 4!"
ero
ero16mo ago
it's not that big of a difference lol c# is c#
Lemur2591
Lemur259116mo ago
if c# is c# I wouldn't have a million and one errors with FNA
ero
ero16mo ago
hard to believe that's a modern .net issue
Lemur2591
Lemur259116mo ago
it might not be, but I do not that the lib it's built on REFUSES TO WORK if not 4.0
ero
ero16mo ago
alright well, i'll let someone else take over then. someone that knows more about webclient and how to use it to make a progress bar in winforms
Lemur2591
Lemur259116mo ago
okay I'm looking at your code for the terminal thing, I didn't know you could use arrow keys in a terminal, this is pretty cool actually
Florian Voß
Florian Voß16mo ago
is there not the System.Net.Http.HttpClient type in the framework that you're using @SynthGirlClip ? its as simple to use as WebClient but it is highly recommended over WebClient, the type WebClient is deprecated. your webclient code should translate very easily over to HttpClient. use that type as @Ero also suggested
ero
ero16mo ago
it's not deprecated in 4.0...
Florian Voß
Florian Voß16mo ago
ohh mhmm but they dont have HttpClient? would be better to use either way right?
ero
ero16mo ago
they don't
Florian Voß
Florian Voß16mo ago
kk then forget what i said
Lemur2591
Lemur259116mo ago
I'll just translate everything to spectre 🤷‍♀️
ero
ero16mo ago
why anyone would want to stick to a framwork that's been out of support for over 7 years is beyond me which is why i don't really feel like helping any further
Florian Voß
Florian Voß16mo ago
yeah especially in a new project not even any ressources to respect or money in old project old version is fine but new project = new version @SynthGirlClip
ero
ero16mo ago
shmeep shmop "i need to use the same framework as the other project because otherwise i won't know how the other framework version works 😭 " invalid argument
Lemur2591
Lemur259116mo ago
Wish me luck, I'm gonna try to make the whole extract file thing in the spectre thing This btw It was answered before the new fella showed up
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
❔ 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 b❔ 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