Get web directory

  • Thread starter Thread starter Peter Bladh
  • Start date Start date
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
 
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();
 
Back
Top