473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting list of files in directory from a web site

Opa
Hi,

Does anyone know how to get a list of files for a given directory from a
given url.
I have the following, but get an error indicating that URI formats are not
supported.

System.IO.DirectoryInfo di
di = new System.IO.DirectoryInfo("http://www.websitehere.com/files/");
System.IO.FileInfo[] rgFiles = di.GetFiles("*.jpg");
foreach(System.IO.FileInfo fi in rgFiles)
{
MessageBox.Show (fi.Name);
}

Is there a way of doing this without ftp?

Nov 22 '05 #1
8 10155
The web site must allow directoy browsing, and the result you get back from
requesting a dir with no default directoy could be parsed. If it has a
default page set you cant list the dir contents. This is how web servers
work by design.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Opa" <Op*@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Hi,

Does anyone know how to get a list of files for a given directory from a
given url.
I have the following, but get an error indicating that URI formats are not
supported.

System.IO.DirectoryInfo di
di = new System.IO.DirectoryInfo("http://www.websitehere.com/files/");
System.IO.FileInfo[] rgFiles = di.GetFiles("*.jpg");
foreach(System.IO.FileInfo fi in rgFiles)
{
MessageBox.Show (fi.Name);
}

Is there a way of doing this without ftp?

Nov 22 '05 #2
Opa,

No what you ask is typical FTP and than the directory has to be on a FTP
server (and be configured there as an ftp directory).

For HTTP this should normally absolute be impossible and therefore made
every day more impossible.

I hope this helps a little bit.

Cor
Nov 22 '05 #3
Hi Cor,
For HTTP this should normally absolute be impossible and therefore made
every day more impossible.


If directory browsing is turned on for the site, then this works just fine.
If you look at the RFC for HTTP 1.1, you will see that directory browsing is
a normal and supported use of HTTP. In fact, it was the original use.
Default pages were a later invention.

http://www.w3.org/Protocols/rfc2068/rfc2068

By the way, there is nothing wrong with doing this if all your pages are
simple text or HTML. There are many tens of thousands of older web sites
that still operate this way. This is not a security risk if the site
contains only text (and some still do).

--- Nick
Nov 22 '05 #4
Hi Nick,

Can you show me a sample how to do that getting a "List of files in a
directory from a website" with HTTP 1.1

I am as well very interested in that

Cor
For HTTP this should normally absolute be impossible and therefore made
every day more impossible.
If directory browsing is turned on for the site, then this works just

fine. If you look at the RFC for HTTP 1.1, you will see that directory browsing is a normal and supported use of HTTP. In fact, it was the original use.
Default pages were a later invention.

http://www.w3.org/Protocols/rfc2068/rfc2068

By the way, there is nothing wrong with doing this if all your pages are
simple text or HTML. There are many tens of thousands of older web sites
that still operate this way. This is not a security risk if the site
contains only text (and some still do).

--- Nick

Nov 22 '05 #5
Sure Cor,

1) open any web site on your web server or create a new one. put a text or
simple HTML file in it. I called mine "mynewsite"
2) open the properties for that site in IIS manager. Check "allow directory
browsing". click OK
3) using IE, hit your site, but don't specify any file name.
http://localhost/mynewsite

you will get a list of the files in the site with a link under each
filename. click the link to open the page.

I'm on Windows 2000 here (I'm at home... I have XP and WS2003 at work). I
set this up in about 2 minutes.

--- Nick

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hi Nick,

Can you show me a sample how to do that getting a "List of files in a
directory from a website" with HTTP 1.1

I am as well very interested in that

Cor
For HTTP this should normally absolute be impossible and therefore made every day more impossible.
If directory browsing is turned on for the site, then this works just

fine.
If you look at the RFC for HTTP 1.1, you will see that directory browsing is
a normal and supported use of HTTP. In fact, it was the original use.
Default pages were a later invention.

http://www.w3.org/Protocols/rfc2068/rfc2068

By the way, there is nothing wrong with doing this if all your pages are
simple text or HTML. There are many tens of thousands of older web

sites that still operate this way. This is not a security risk if the site
contains only text (and some still do).

--- Nick


Nov 22 '05 #6
Did anyone ever answer your question?

Use HTTPWebClient. I don't know if you can use the URI of .../files/*.jpg
or if you have to just say .../files/* and then look for the JPG files.

Note: this will only work if the web server has directory browsing turned on
for this site.

I don't know if you get the same HTTP response with different web servers.
I would suspect that you do, but I haven't dug far enough into the W3C RFCs
to see if there's a standard for returning the file list.

--- Nick

"Opa" <Op*@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Hi,

Does anyone know how to get a list of files for a given directory from a
given url.
I have the following, but get an error indicating that URI formats are not
supported.

System.IO.DirectoryInfo di
di = new System.IO.DirectoryInfo("http://www.websitehere.com/files/");
System.IO.FileInfo[] rgFiles = di.GetFiles("*.jpg");
foreach(System.IO.FileInfo fi in rgFiles)
{
MessageBox.Show (fi.Name);
}

Is there a way of doing this without ftp?

Nov 22 '05 #7
Nick,

I did not know this, however doing it I saw there should as well not be a
default page in that folder.

(Just for the thread)

Thanks,

Cor
1) open any web site on your web server or create a new one. put a text or simple HTML file in it. I called mine "mynewsite"
2) open the properties for that site in IIS manager. Check "allow directory browsing". click OK
3) using IE, hit your site, but don't specify any file name.
http://localhost/mynewsite

you will get a list of the files in the site with a link under each
filename. click the link to open the page.

I'm on Windows 2000 here (I'm at home... I have XP and WS2003 at work). I
set this up in about 2 minutes.

Nov 22 '05 #8


May b error is coming because IIS is not configured to be for *.jpg.

please read the following article.
http://support.microsoft.com/default...b;en-us;326965

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Opa | last post by:
Hi, Does anyone know how to get a list of files for a given directory from a given url. I have the following, but get an error indicating that URI formats are not supported. ...
3
by: Mary Jane Pronio | last post by:
What I want to do is take that output, use the data within it to put into a shell script as input to another installation of DB2 Connect on another AIX box. Any ideas about how to do this?
8
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to...
7
by: chuckdfoster | last post by:
I am not sure if this is even possible, but I figured I'd ask some experts. How would I use an ASP.NET page to get a listing of all of the files that are in a folder. I am working on a page that...
0
by: Don | last post by:
I intermittently get a runtime Compilation Error that says 'The compiler failed with error code 2000'. It appears that a DLL cannot be found in the 'temporary asp.net files' directory. The...
1
by: Shawn Mehaffie | last post by:
I have an application I want to be able to: 1) Store user specifc settings in ther "My Documents". 2) Store some information in "All Users" document directory. 3) I also want to be able to...
1
by: dcruncher4 | last post by:
DB2 8.2.3 is there a sql equivalent to get the information provided by db2 list node directory db2 list db directory. thanks.
1
by: mmohanra | last post by:
I am trying to list files in a folder in a remote server. I am using Scripting.FileSystemObject. This seems to be really slow. After a long time the connection times out. Is there any other way to...
3
by: froditus | last post by:
Hello everyone, is it possible to list files from directory other than in apache web directory? my web folder is placed on c:/ and i put my files in windows directory "d:/files/images/". I...
5
by: Ned White | last post by:
I have set up a virtual directory on ISS 6.0 to store the all .jpg and .swf files which i use in my project It is alias name is "OutSrc" Is it possible to acquire a list of files which exist in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.