Click here to Skip to main content
13,000,017 members (47,320 online)
Rate this:
Please Sign up or sign in to vote.
See more:
how can i get a list of folders from a website? Namely I wrote a program that take a URL And give a list of folders from the website.
I try

but it not work.
Posted 11-Jul-13 8:06am
ThePhantomUpvoter 11-Jul-13 14:13pm
You would need to ask the web site owner, nicely, to have a list of folders on his website. Or provide a way for you to query that information.
pasztorpisti 11-Jul-13 15:14pm
I don't know about any REQUEST METHOD in the HTTP PROTOCOL that could be used to list directories. More about the HTTP protocol here: You can download a file (GET) or upload a file (PUT) but there is not directory listing operation. A web server may generate you a directory listing "html page" that is not standard parsable data but even this directory listing is usually disabled by default. Once I needed a directory listing feature and I implemented it as a custom HTTP request (LISTDIR) with a python cgi script.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Considering very few websties ever give you browse access to their file system, you're going to have a hard time finding a website that this tool will work with.

The Directory class only works with local file systems. It will not work over HTTP, meaning you can't use it for getting the list of directories on a website.

You would have to use the HttpWebRequest class with web URLs and parse the result you get back, if any.
karimi5555 11-Jul-13 14:30pm
may further explain please
Dave Kreskowiak 11-Jul-13 15:14pm

You would have to request the URL you're trying to get the directory list for, usually ending in a forward slash, like this:

IF folder browsing is turned on, you'll get back a page listing the directories in the root of the web site. You parse this text (it's just a string!) and pull out the directory names and links to subdirectories.

But, NOBODY in their right mind will turn folder browsing on for their site. Doing so just gives people who want to break into your site more information on how to do it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100