C # Download a file from a directory and run it

With this code, I can upload a file, but I need to know the file name. Is there a way to upload any file to a 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"); } 
+4
source share
3 answers

Dropbox has a REST API, so you just need to do an HTTP GET at the appropriate URL to get the contents of the folder. Take a look at / metadata for a link to the Dropbox API . This will give you the contents of the folder if you pass the list = true and you can parse the response to get the file name. Then you can upload the file.

+4
source

You already have a download part. Assuming this is a bootable Windows EXE, after downloading it, you can start it using Process.Start .

Edit: This question seems to give some ideas on how to do this. Basically, you create an HttpWebRequest using the URL of the directory you have, and then you have to parse what is returned here to get a list of the files contained in this directory (which can be just one file). After that, you can download this file in the usual way.

0
source

When you start the download via DownloadFileAsync , you need to specify the file name anyway. Just use this name and pass it to Process.Start , as MusiGenesis suggested.

0
source

All Articles