Reputation: 7043
With this code I can download the file but I should know the file name. Is there any way to download whatever file at the directory (Directory link: https://www.dropbox.com/sh/koao8dlfpcao8sk/XzDZMfejiF) and run it?
private void Update_Load(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("https://www.dropbox.com/s/6o5kvzr7s0c6mne/Test.txt"), @"C:\Users\Admin\Downloads\Test.txt");
}
Upvotes: 4
Views: 2008
Reputation: 75296
You seem to already have the downloading part covered. Assuming this is a Windows EXE that you're downloading, after it's downloaded you can run it using Process.Start.
Edit: This question seems to provide some ideas of how to do this. Basically you make an HttpWebRequest using the directory URL you have, and then you have to parse what's returned here in order to get a list of the files contained in that directory (which may just be a single file). Once you have that, you can download that file in the normal way.
Upvotes: 0
Reputation: 2394
Dropbox has a REST API, so you just need to do an HTTP GET on the appropriate URL to get the folder's content. Look at /metadata in the dropbox API reference. That'll give you the contents of the folder if you pass list=true, and you can parse the response to get the filename. Then you can download the file.
Upvotes: 4
Reputation: 7192
When you start the download via DownloadFileAsync you need to specify a file name anyway. Just use that name and pass it to Process.Start as MusiGenesis suggested.
Upvotes: 0