• Post Reply Bookmark Topic Watch Topic
  • New Topic

file names of files in a url

 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a directory accesible over the internet and this directory has a set of sub-directories...I need to get the names of all these sub-directories...I have the url to the parent directory...so how can I get the names of all the sub-directories?

Thanks
 
Paul Clapham
Sheriff
Posts: 21872
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean accessible via HTTP? Sorry, HTTP doesn't really support the concept of "directory" very well.

It's possible to configure a website so that an HTTP request for a directory will return a formatted directory of the files in that directory. But that option is usually turned off, because it can lead to people snooping into places they shouldn't be. But you can turn it on if you like. Just be aware that you're going to get an HTML document that includes, somehow, the list of files and subdirectories. There are no standards for formatting this document, so the format you get will depend on what server it comes from. And you will have to write code to scrape the HTML and extract the file names.

So start by configuring your server, then use a browser to connect to the directory with the URL you have and see what you get.
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for answering....I figured it out...(well the hard way....searching for a while through google)...

Well I solved the issue....I had a virtual directory exposed thru IIS to start with...so all I had to do was to give it as :

File file = new File("//ip/virtualdirectory");
File[] files = file.listFiles();

Thanks
Preetham
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!