Getting application location!

D

DBC User

Hi,

I have a program sitting in the network, when I double click the
program, first thing I want to do is find the application execution
path. I am using the following code

Assembly execAssembly =
System.Reflection.Assembly.GetExecutingAssembly();
string path = Path.GetPathRoot(execAssembly.Location);

When I run I get security execption on the execAssembly.Location

Does anyone know how to resolve this problem?

Thanks.
 
G

Guest

You already have the path to the assembly in "execAssembly.Location". If you
call Path.GetPathRoot on that, it's going to give you the root of the drive.

If you are doing this to a remote machine, you will have a permissions issue
by default. You'll need to adjust security to fix that. One way to do it is
to use the Control Panel .NET Configuration wizards and grant "full trust" on
the remote assembly.
--Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 

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