Get web directory

P

Peter Bladh

Hi

How can I programmaticly browse a folder on a web server that allows
directory browsing? Retrieving a file with HttpWebRequest works, but the
response length is -1 if I ask for a folder (a web browser, such as IE or
Netscape, shows a html page with links to the files in the folder).

/peter bladh
 
P

Peter Bladh

Hi again

I solved it! If anyone's interested here's som info:

The html page that is generated by iis doesn't contain a content-length
header. That's why it seemed empty (it also lacks <html></html> which is
weired).
It's possible to read the stream like this even if you don't know the
contents lenght (there's other ways too):

StreamReader stream = new StreamReader(response.GetResponseStream(),
Encoding.ASCII);
string str = stream.ReadToEnd();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top