How can I download a file, then save it to wherever I want? I am using Windows Form, Web Application.
I know I can download it with this code:
WebClient wClient = new WebClient();
wClient.DownloadFile("WebLinkHere", @"C:\File.txt");
But I want a save box like when you press CTRL+S.
You can use SaveFileDialog class. Example:
var dialog = new SaveFileDialog();
dialog.Filter = "Archive (*.rar)|*.rar";
var result = dialog.ShowDialog(); //shows save file dialog
if(result == DialogResult.OK)
{
Console.WriteLine ("writing to: " + dialog.FileName); //prints the file to save
var wClient = new WebClient();
wClient.DownloadFile("WebLinkHere", dialog.FileName);
}
will show next dialog and if you search for next folder
application will print:
writing to: C:\Temp\archiveName.rar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With