How to get the application path :S

D

Developer.Man4

Dear friends :)

i need a hand guys

i'm implementing a small program to list all virtual directories to
the user and give him some facilities to move or delete these files,
fine??

i can easily retrieve the list of all virtual directories using the
code below
System.DirectoryServices.DirectoryEntry iISAdmin = new
System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/
root");

then where is the problem, thats a good question :)
my problem that i've been facing for 3 days now, or even more, is that
how can i get the physical or actual path of the virtual path returned
from the code snippet above.

for example i get from the above piece of code "IIS://localhost/W3SVC/
1/root/Webapplication1"
but i can't send this path as an argument to File.move() or
File.delete(), i get a not supported format exception


what am i using, thats another good question :) :), i'm using VS2003,
c# IIS6
P.S. this program i'm trying to develop is a desktop application and
not a web application for security wise.

Thank you all and waiting eagerly for ur replies
 
P

Patrick Steele

i'm implementing a small program to list all virtual directories to
the user and give him some facilities to move or delete these files,
fine??

i can easily retrieve the list of all virtual directories using the
code below
System.DirectoryServices.DirectoryEntry iISAdmin = new
System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/
root");

then where is the problem, thats a good question :)
my problem that i've been facing for 3 days now, or even more, is that
how can i get the physical or actual path of the virtual path returned
from the code snippet above.

string path = iISAdmin.Properties["Path"].Value.ToString();
 
D

Developer.Man4

Thanks patrick for the gr8 help :)

butr when i try it i get System.Reflection.TargetInvocationException
any ideas why and how to solve it??



i'm implementing a small program to list all virtual directories to
the user and give him some facilities to move or delete these files,
fine??
i can easily retrieve the list of all virtual directories using the
code below
System.DirectoryServices.DirectoryEntry iISAdmin = new
System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/
root");
then where is the problem, thats a good question :)
my problem that i've been facing for 3 days now, or even more, is that
how can i get the physical or actual path of the virtual path returned
from the code snippet above.

string path = iISAdmin.Properties["Path"].Value.ToString();
 
D

Developer.Man4

thanks patrick for the great help :D
but when i try this it i get
System.Reflection.TargetInvocationException

any ideas why and how to solve it??


i'm implementing a small program to list all virtual directories to
the user and give him some facilities to move or delete these files,
fine??
i can easily retrieve the list of all virtual directories using the
code below
System.DirectoryServices.DirectoryEntry iISAdmin = new
System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/
root");
then where is the problem, thats a good question :)
my problem that i've been facing for 3 days now, or even more, is that
how can i get the physical or actual path of the virtual path returned
from the code snippet above.

string path = iISAdmin.Properties["Path"].Value.ToString();
 
P

Patrick Steele

thanks patrick for the great help :D
but when i try this it i get
System.Reflection.TargetInvocationException

any ideas why and how to solve it??

Hmmmm... I just started with your code and dug around to find the
Properties collection and what was in it. What's the InnerException of
the TargetInvocationException?
 
E

eng.rana

actually i found that it throws this exception because the local path
is not stored in the properties of the application its self under iis.
ratherthan having the full path /theapplicationname is stored, thus
the hresult of the request is not defined and hence it throws this
exception
 

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