473,387 Members | 1,304 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,387 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 10169
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.