Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

DownloadFileAsync Create Directory?

I have a script that downloads a bunch of files from a list. I am using DownloadFileAsync since it allows me to use the progress bar.

Lets say my list looks like this:
Code
/directory1/directory2/directory3/file.txt
/directory1/directory4/file2.txt
/directory1/file3.txt

If directory1, directory2, and directory3, do not exist, DownloadFileAsync will download the file to nowhere while still showing that the file was downloaded successfully.

What I want to ask is, is there a function or method that creates the directory (or directories) of the path and then downloads file, all while having the progress bar?

This is the DownloadFileAsync code:
Code
Dim _WebClient As New System.Net.WebClient()
       AddHandler _WebClient.DownloadProgressChanged, AddressOf _DownloadProgressChanged
       Label2.Text = "Downloading File 1"
       _WebClient.DownloadFileAsync(New Uri(url_link), download_location)

Edit: Before you say, "Use CreateDirectory", look at the third post in this thread below
Code
Directory.CreateDirectory("path")

This will create all directories and subdirectories needed if they don't already exist.

https://msdn.microsoft.com/en-us/library....110).aspx
(Jul 21, 2018 02:40 PM)SIM-1078643 Wrote:  
Code
Directory.CreateDirectory("path")

This will create all directories and subdirectories needed if they don't already exist.

I should have clarified that this cant work. I pass along the location of where to download the file to DownloadFileAsync but DownloadFileAsync doesnt create the directories. The problem with CreateDirectory is you have to pass the directory to create BEFORE you download the file to that exact directory but the list only has the file list itself.

This list was made by taking a bunch of URL's and stripping out the domain name


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by YUGOBOSSJul 7, 2017 03:41 AM 21 613 Jul 7, 2017 03:41 AM
Last Post: Hackoo
[Shell] by ninen2001Mar 5, 2015 08:15 AM 7 308 Mar 5, 2015 08:15 AM
Last Post: ninen2001
[Java] by PlatypusؚFeb 18, 2015 08:39 PM 3 116 Feb 18, 2015 08:39 PM
Last Post: ▁▂▃▄▅▆M1kep▆▅▄▃▂▁