Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB 2012 List Files on Web

Posted on 2013-12-29
3
Medium Priority
?
363 Views
Last Modified: 2014-01-18
I use VB 2012, and need to download multiple files automatically.

It's easy to download a single file, e.g.

My.Computer.Network.DownloadFile("http://nnn.nnn.nnn.nnn/MyFolder/MyFile.txt", "C:/Temp/MyFile.txt", "MyLogin", "MyPassword", True, 50000, True)

However, I cannot find out how to list all the files in the folder first, so I can then download each one. You'd think it would be My.Computer.Network.GetFiles but there is no such method.

Can anyone help ? It must be VB !
0
Comment
Question by:round3
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39745537
You'll only be able to locate all the files in the folder if the server has directory browsing enabled, which is typically off as a security precaution. The only other way to do it would be the way Googlebot does it:  traverse all links on the site--in this instance, you would only get everything if everything is linked.
0
 

Author Comment

by:round3
ID: 39745735
OK, so if I enable directory browsing on my website, what is the VB.Net code to obtain the listing ?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1000 total points
ID: 39754955
There is no direct way of getting the file list from a HTTP directory as far as I know. One option is to use the directory address in WebClient.DownloadString method which will get you the HTML of the page with list of all the files (as seen in IE if you browse the directory) and then you can use some string manipulation/regex to extract the file names.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Loops Section Overview

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question