C
C#2y 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
ero2y ago
why make a program that downloads something a whole winforms app? why not just a simple console?
Lemur2591
Lemur2591OP2y ago
aren't consoles not really user friendly?
ero
ero2y ago
they can be made to be $spectre
MODiX
MODiX2y 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
ero2y ago
spectre also has progress bars a console app will also be cross platform, unlike a winforms app
Lemur2591
Lemur2591OP2y 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
ero2y ago
are you under some time constraint?
Lemur2591
Lemur2591OP2y ago
no, but I think I would rather have it done in the next few hours, otherwise I don't feel productive
ero
ero2y ago
i'd say learning some new concepts is being pretty damn productive
Lemur2591
Lemur2591OP2y 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
ero2y 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
Lemur2591OP2y ago
you know what, I'll entertain the idea. do you think it'll be easier to achieve what I want using console?
ero
ero2y ago
mhh... no! i assume you're more of a beginner in c#?
Lemur2591
Lemur2591OP2y ago
THEN WHY SUGGEST IT? 😭
ero
ero2y 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
Lemur2591OP2y 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
ero2y 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
Lemur2591OP2y 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
ero2y ago
i'm not sure about the pause/cancel during the download everything else is easy
Lemur2591
Lemur2591OP2y 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
ero2y ago
a console app chooses whatever design you have for your preferred terminal
Lemur2591
Lemur2591OP2y 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
ero2y ago
depends on how you implemented it i guess?
Lemur2591
Lemur2591OP2y ago
hey doesn't this seem like a direct download in every possible category to you?
ero
ero2y ago
hm?
Lemur2591
Lemur2591OP2y 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
ero2y ago
ero
ero2y 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
Lemur2591OP2y 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
ero2y 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
Lemur2591OP2y ago
like, I use visual studio, and I use winforms in visual studio so like, what do I do with this?
ero
ero2y ago
it's a console app you create a new console app project, install the spectre.console nuget, and you're done
Lemur2591
Lemur2591OP2y ago
I just open the console app preset on vs? gotcha
ero
ero2y ago
$newproject
MODiX
MODiX2y 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
ero2y ago
try to use .net 7 install it if you don't have it yet
Lemur2591
Lemur2591OP2y ago
I would but I've got certain limitations
ero
ero2y ago
hm?
Lemur2591
Lemur2591OP2y ago
I have to use 4.0 only
ero
ero2y ago
why?
Lemur2591
Lemur2591OP2y ago
the game I'm working on was made in XNA in 2013
ero
ero2y ago
is wow not on linux or mac?
Lemur2591
Lemur2591OP2y ago
no no that's something different I'm talking about charlier murder, I want my experience to translate though
ero
ero2y ago
i still don't really see how that has to do with the framework this installer is made in though
Lemur2591
Lemur2591OP2y ago
it doesn't I want my experience to translate though
ero
ero2y ago
i don't understand
Lemur2591
Lemur2591OP2y 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
ero2y ago
it's not that big of a difference lol c# is c#
Lemur2591
Lemur2591OP2y ago
if c# is c# I wouldn't have a million and one errors with FNA
ero
ero2y ago
hard to believe that's a modern .net issue
Lemur2591
Lemur2591OP2y ago
it might not be, but I do not that the lib it's built on REFUSES TO WORK if not 4.0
ero
ero2y 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
Lemur2591OP2y 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ß2y 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
ero2y ago
it's not deprecated in 4.0...
Florian Voß
Florian Voß2y ago
ohh mhmm but they dont have HttpClient? would be better to use either way right?
ero
ero2y ago
they don't
Florian Voß
Florian Voß2y ago
kk then forget what i said
Lemur2591
Lemur2591OP2y ago
I'll just translate everything to spectre 🤷‍♀️
ero
ero2y 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ß2y 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
ero2y 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
Lemur2591OP2y 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
Accord2y 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