Home All Groups Group Topic Archive Search About

How to get the application path :S

Author
5 Feb 2007 12:56 PM
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

Author
6 Feb 2007 2:58 AM
Patrick Steele
In article <1170680202.777209.21***@j27g2000cwj.googlegroups.com>,
Developer.M***@gmail.com says...
Show quote
> 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();

Author
6 Feb 2007 8:02 AM
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??



On Feb 6, 4:58 am, Patrick Steele <patr***@mvps.org> wrote:
Show quote
> In article <1170680202.777209.21***@j27g2000cwj.googlegroups.com>,
> Developer.M***@gmail.com says...
>
> > 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();
>
> --
> Patrick Steelehttp://weblogs.asp.net/psteele
Author
6 Feb 2007 8:03 AM
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??


On Feb 6, 4:58 am, Patrick Steele <patr***@mvps.org> wrote:
Show quote
> In article <1170680202.777209.21***@j27g2000cwj.googlegroups.com>,
> Developer.M***@gmail.com says...
>
> > 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();
>
> --
> Patrick Steelehttp://weblogs.asp.net/psteele
Author
6 Feb 2007 12:31 PM
Patrick Steele
In article <1170749017.322006.221***@v33g2000cwv.googlegroups.com>,
Developer.M***@gmail.com says...
> 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?

Author
7 Feb 2007 11:23 AM
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


On Feb 6, 2:31 pm, Patrick Steele <patr***@mvps.org> wrote:
Show quote
> In article <1170749017.322006.221***@v33g2000cwv.googlegroups.com>,
> Developer.M***@gmail.com says...
>
> > 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?
>
> --
> Patrick Steelehttp://weblogs.asp.net/pstee

AddThis Social Bookmark Button