Reputation: 15197
I am downloading a file off a website and it always saves into my Download files, is there a way where i can select where to save the file to?
public void myDownloadfile(string token, string fileid, string platform)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("Token", token);
parameters.Add("fileid", fileid);
parameters.Add("plateform", platform);
string url;
url = "https://formbase.formmobi.com/dvuapi/downloadfile.aspx?" + "token=" + token + "&fileid=" + fileid + "&platform=" + platform;
System.Diagnostics.Process.Start(url);
}
Upvotes: 0
Views: 4141
Reputation: 17194
You can use HttpResponse
.
Go through the link: prompt a save dialog box to download a file
Upvotes: 0
Reputation: 17522
Don't use Process.Start that will launch the default browser to download the file and the download location will be very dependent on the users system settings. Use WebClient to download it instead and it will be easier to specify a location.
public void myDownloadfile(string token, string fileid, string platform)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("Token", token);
parameters.Add("fileid", fileid);
parameters.Add("plateform", platform);
string url;
url = "https://formbase.formmobi.com/dvuapi/downloadfile.aspx?" + "token=" + token + "&fileid=" + fileid + "&platform=" + platform;
System.Net.WebClient wc = new System.Net.WebClient()
wc.DownloadFile(url, "C:\\myFile.ext")
}
Upvotes: 1
Reputation: 2276
You can use WebClient to download the data and use SaveFile Dialog to set the default location where you which to start.
Upvotes: 0
Reputation: 101052
Since you are downloading the file using your system's standard browser, you have to change the setting there.
Otherwise, you probably want to use the WebClient
class to download a file, since it is as easy to use as
using System.Net;
WebClient webClient = new WebClient();
webClient.DownloadFile("http://mysite.com/myfile.txt", @"c:\myfile.txt");
(example from here)
Upvotes: 5
Reputation: 2208
System.Diagnostics.Process.Start
just opens your default web browsers on the required url.
You can set your browser to open save as dialog.
But better use WebClient.DownloadFile
: http://msdn.microsoft.com/en-us/library/ez801hhe.aspx
It receives the path of the target file as one of it's parameters.
Upvotes: 5