C# checkbox direct download file
I have trouble assinging a download to checkbox , for starters in the event of checking to download a specific file in the current folder. I plan to add cancel+delete on unchecked later... if I get this working
The problem is that it creates an empty file , but the download never occurs.
I really want it to download on check, without using a separate button that triggers the event.
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
down.DownloadFileAsync(new Uri(address), filename);
}
private void Autor_Checked(object sender, RoutedEventArgs e)
{
downloadFile("https://live.sysinternals.com/autoruns.exe", "autoruns.exe");
}
c# checkbox download
add a comment |
I have trouble assinging a download to checkbox , for starters in the event of checking to download a specific file in the current folder. I plan to add cancel+delete on unchecked later... if I get this working
The problem is that it creates an empty file , but the download never occurs.
I really want it to download on check, without using a separate button that triggers the event.
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
down.DownloadFileAsync(new Uri(address), filename);
}
private void Autor_Checked(object sender, RoutedEventArgs e)
{
downloadFile("https://live.sysinternals.com/autoruns.exe", "autoruns.exe");
}
c# checkbox download
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
You should put theDownloadFileAsync
in atry/catch
block. And update your question with the exception.
– Black Frog
Nov 24 '18 at 4:29
add a comment |
I have trouble assinging a download to checkbox , for starters in the event of checking to download a specific file in the current folder. I plan to add cancel+delete on unchecked later... if I get this working
The problem is that it creates an empty file , but the download never occurs.
I really want it to download on check, without using a separate button that triggers the event.
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
down.DownloadFileAsync(new Uri(address), filename);
}
private void Autor_Checked(object sender, RoutedEventArgs e)
{
downloadFile("https://live.sysinternals.com/autoruns.exe", "autoruns.exe");
}
c# checkbox download
I have trouble assinging a download to checkbox , for starters in the event of checking to download a specific file in the current folder. I plan to add cancel+delete on unchecked later... if I get this working
The problem is that it creates an empty file , but the download never occurs.
I really want it to download on check, without using a separate button that triggers the event.
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
down.DownloadFileAsync(new Uri(address), filename);
}
private void Autor_Checked(object sender, RoutedEventArgs e)
{
downloadFile("https://live.sysinternals.com/autoruns.exe", "autoruns.exe");
}
c# checkbox download
c# checkbox download
asked Nov 24 '18 at 3:43
erma86erma86
2817
2817
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
You should put theDownloadFileAsync
in atry/catch
block. And update your question with the exception.
– Black Frog
Nov 24 '18 at 4:29
add a comment |
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
You should put theDownloadFileAsync
in atry/catch
block. And update your question with the exception.
– Black Frog
Nov 24 '18 at 4:29
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
You should put the
DownloadFileAsync
in a try/catch
block. And update your question with the exception.– Black Frog
Nov 24 '18 at 4:29
You should put the
DownloadFileAsync
in a try/catch
block. And update your question with the exception.– Black Frog
Nov 24 '18 at 4:29
add a comment |
2 Answers
2
active
oldest
votes
You're missing where the file is supposed to be downloaded to. This would download it to C:test:
down.DownloadFileAsync(new Uri("https://live.sysinternals.com/autoruns.exe"), @"C:testautoruns.exe");
Though you'll probably want to know when it finishes, so you'll have to add handlers as well.
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
|
show 2 more comments
Found the solution. It seems NF 3.5 doesn't support TLS 1.2 by default wich was requiered for sysinternals to accept the connection.
Had to adjust my code to:
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
down.DownloadFileAsync(new Uri(address), filename);
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454980%2fc-sharp-checkbox-direct-download-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're missing where the file is supposed to be downloaded to. This would download it to C:test:
down.DownloadFileAsync(new Uri("https://live.sysinternals.com/autoruns.exe"), @"C:testautoruns.exe");
Though you'll probably want to know when it finishes, so you'll have to add handlers as well.
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
|
show 2 more comments
You're missing where the file is supposed to be downloaded to. This would download it to C:test:
down.DownloadFileAsync(new Uri("https://live.sysinternals.com/autoruns.exe"), @"C:testautoruns.exe");
Though you'll probably want to know when it finishes, so you'll have to add handlers as well.
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
|
show 2 more comments
You're missing where the file is supposed to be downloaded to. This would download it to C:test:
down.DownloadFileAsync(new Uri("https://live.sysinternals.com/autoruns.exe"), @"C:testautoruns.exe");
Though you'll probably want to know when it finishes, so you'll have to add handlers as well.
You're missing where the file is supposed to be downloaded to. This would download it to C:test:
down.DownloadFileAsync(new Uri("https://live.sysinternals.com/autoruns.exe"), @"C:testautoruns.exe");
Though you'll probably want to know when it finishes, so you'll have to add handlers as well.
answered Nov 24 '18 at 4:19
Nathan ChampionNathan Champion
702315
702315
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
|
show 2 more comments
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
That wasn't the issue. If not path given it is downloaded in the app folder. The issue seems to be the link itself. While it downloads perfectly in browser, it doesn't seem to work in this case.
– erma86
Nov 24 '18 at 4:38
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
So, what happens then exactly? Using that code I get the autoruns.exe file. Same file-size as downloading via a web-browser.
– Nathan Champion
Nov 24 '18 at 4:47
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
just a file called autoruns.exe of 0kb is created. Ccleaner link portable and it gets downloaded without any issue
– erma86
Nov 24 '18 at 4:51
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
I get the file as intended, have you tried capturing the error messages? Or adding a handler for DownloadFileCompleted ? imgur.com/a/j2M6lu4 is what I get and it works fine.
– Nathan Champion
Nov 24 '18 at 5:01
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
how would I go about capturing the error messages? Not sure what's wrong. Tried different links for other tools, and the only ones that cause this problem are the ones from live.sysinternals.com
– erma86
Nov 24 '18 at 5:36
|
show 2 more comments
Found the solution. It seems NF 3.5 doesn't support TLS 1.2 by default wich was requiered for sysinternals to accept the connection.
Had to adjust my code to:
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
down.DownloadFileAsync(new Uri(address), filename);
}
add a comment |
Found the solution. It seems NF 3.5 doesn't support TLS 1.2 by default wich was requiered for sysinternals to accept the connection.
Had to adjust my code to:
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
down.DownloadFileAsync(new Uri(address), filename);
}
add a comment |
Found the solution. It seems NF 3.5 doesn't support TLS 1.2 by default wich was requiered for sysinternals to accept the connection.
Had to adjust my code to:
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
down.DownloadFileAsync(new Uri(address), filename);
}
Found the solution. It seems NF 3.5 doesn't support TLS 1.2 by default wich was requiered for sysinternals to accept the connection.
Had to adjust my code to:
public void downloadFile(String address, String filename)
{
WebClient down = new WebClient();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
down.DownloadFileAsync(new Uri(address), filename);
}
answered Nov 24 '18 at 13:15
erma86erma86
2817
2817
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454980%2fc-sharp-checkbox-direct-download-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of How to download an .EXE file from a website?
– Max Jacobi
Nov 24 '18 at 4:17
You should put the
DownloadFileAsync
in atry/catch
block. And update your question with the exception.– Black Frog
Nov 24 '18 at 4:29