C
C#ā€¢2y ago
Error101

ā” I'm trying to download a link in 4 chunks via HttpClient but it keeps breaking.

Link to my GitRepository https://github.com/Error1OH1/FileDownloader I've been trying to download in 4 chunks but I can't seem to get the file to download in 4 chunks properly it loops through but always ends up only being a quarter of the download, and this new updated code just breaks but downloads a 0 KB file.
GitHub
GitHub - Error1OH1/FileDownloader
Contribute to Error1OH1/FileDownloader development by creating an account on GitHub.
62 Replies
Damien
Damienā€¢2y ago
You can do this to do a c sharp codeblock
You can do this to do a c sharp codeblock
```cs
```cs
```
```
makes it easier to read in discord couldnt get it to work yet but I did see this
Damien
Damienā€¢2y ago
i used a snippet of ur code to show u
Damien
Damienā€¢2y ago
I put answers with comments in that pull request šŸ™‚
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I am okay with rewriting it for the sake of learning but could you explain why first
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Oh I used that because I was having a hard time understanding how to use httpclient and was basing it off a friends
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
What do you mean It's a console application if that is what you mean
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I'm still new to programming Does this cause corruption if I do?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
OH I THINK I GET WHAT YOU MEAN IN MY CLASS USE THE SAME FOR ALL THE METHODS
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
SO CALL IT OUTSIDE OF THE METHODS AS PUBLIC USE
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I was trying to create an HttpClient Library class so I could use it for future projects easier Is that what broke it?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Also, I am far from knowledgeable with async I barely understand how it's working in my use.
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Also couldn't I do it non asynchronous via .result and .wait();?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiXā€¢2y ago
TLDR on async/await: * every .net API that is suffixed with Async (eg: .Read() and .ReadAsync()) => use the Async version * if the API name ends with Async => await it * if the API returns a Task => await it * if you have to await in a method: * that method must have the async keyword (you could even suffix your function name with Async, up to you) * if it was returning T (eg:string) => it should now return Task<T> (eg: Task<string>) * APIs to ban and associated fix:
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
Error101
Error101OPā€¢2y ago
That is extremely helpful Thank you What API?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I have a friend who has already worked in this field and is pretty good at coding and he had me use it
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
That's definitely why
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I've been kind of using him as a roadmap on what I should do next and since I am kind of slow at learning he probably just trying to make it easier
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Not literally a roadmap
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I just ask for project ideas
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
What experience have you had with C#?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Oh shit since I was born šŸ¤£
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
That's awesome dude
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I'm assuming you aren't American?
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
You keep saying these Instead of "This"
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
or it could be these kind(s)
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I feel like we are diverting from the topic lmao
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I'm going to rewrite the code with what you've provided Dude if one word and plurals are all you are messing up on it's nothing to worry about
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
People on Discord don't necessarily talk to each other like they would in real life and put out more unnecessary flare to what they say, so it makes it more difficult. Even English users have difficulty understanding each other on online applications.
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
I've only been coding for 3 months so it was more of just an attempt
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
Dude What I didn't do this
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
It was more than likely systematically put their based on my code
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Error101
Error101OPā€¢2y ago
The goal is for downloading faster again I am still new and 4 was just the number I chose They are meant to download in parallel
Accord
Accordā€¢2y 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