Get directory listing from a web server

P

Pete Kane

Hello all, how do I get a directory listing from a web server ?, I'm
playing around with reflection and "Click once" deployment and would
like to loop through a directory listing and use Assembly.LoadFrom(dllname)

many thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You could use Directory.GetFiles . IIRC you cannot use reflection for this,
you have to use Server.MapPath to get hte physical path.
 
P

Pete Kane

Ignacio said:
Hi,

You could use Directory.GetFiles . IIRC you cannot use reflection for this,
you have to use Server.MapPath to get hte physical path.
Hello Ignacio, thanks for your reply, I take it Directory.GetFiles takes
a web addresss as a parameter ?

cheers
 
P

Pete Kane

Ignacio said:
Hi,

You could use Directory.GetFiles . IIRC you cannot use reflection for this,
you have to use Server.MapPath to get hte physical path.
Just thought I would clarify the way I'm trying to retrieve this
directory listing, I'm not using Asp, my app is a Windows form app
which loads all needed assemblies from a remote web site, the way I do
it now is:

string f1 = "mydll1.dll";
string f2 = "mydll2.dll";
....
string url = @"http://mywebsite.com/Assemblies/";

Assembly.LoadFrom(url + f1)
....
etc...
which is horrible but it works, I would like to read all the files
directly and loop through them

thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Pete Kane said:
Hello Ignacio, thanks for your reply, I take it Directory.GetFiles takes a
web addresss as a parameter ?

Nop, it takes a local path , that's why you need MapPath for.
 
A

adebaene

Pete said:
Just thought I would clarify the way I'm trying to retrieve this
directory listing, I'm not using Asp, my app is a Windows form app
which loads all needed assemblies from a remote web site, the way I do
it now is:

string f1 = "mydll1.dll";
string f2 = "mydll2.dll";
...
string url = @"http://mywebsite.com/Assemblies/";

Assembly.LoadFrom(url + f1)
...
etc...
which is horrible but it works, I would like to read all the files
directly and loop through them

Most (all?) production web servers disable the ability to browse a
directory content from a web client, for obvious security reasons, so
you're basically out of luck on this one. Can't you create and maintain
a known HTML page (or even plain text file) that contains the list of
your plugins?

Arnaud
MVP - VC
 
P

Pete Kane

Most (all?) production web servers disable the ability to browse a
directory content from a web client, for obvious security reasons, so
you're basically out of luck on this one. Can't you create and maintain
a known HTML page (or even plain text file) that contains the list of
your plugins?

Arnaud
MVP - VC
Looks like I'll have to go that route, thanks all, BTW is MapPath an asp
function ?

regards
 

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