TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Getting application location!

C#(C Sharp)

 
 
Thread Tools Display Modes
Unread 16-10-2007, 03:28 PM   #1
DBC User
Guest
 
Posts: n/a
Getting application location!

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.

 
Unread 16-10-2007, 06:25 PM   #2
Peter Bromberg [C# MVP]
Guest
 
Posts: n/a
RE: Getting application location!

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



"DBC User" wrote:

> 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.
>
>

 
 

Thread Tools
Display Modes



< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 05:32 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional