.NET

Reply
New Member
fergotrash
Posts: 2
Registered: ‎05-12-2014
Message 1 of 4 (167 Views)

Retrieving the plugin path - C#

167 Views, 3 Replies
05-12-2014 05:35 PM

Hello everyone,

 

It's my first post in here. I did a little search for this question but didn't found anything.

 

I'm developing a plugin for Autocad using C#. In the same folder of the plugin DLL, I have subfolder (let's call it "data") that contains a lot of files that my plugin will use. In order to make the program work indepedent of the location of the DLL file (and the subfolder), I need to get the directory of my plugin dll. Anyone knows how can I achieve this? If this was a regular C# Winforms application, I would use "Application.StartupPath", but that's not available when developing an Autocad plugin.

 

Thanks in advance,

Fergo.

Distinguished Mentor
gasty1001
Posts: 539
Registered: ‎04-11-2010
Message 2 of 4 (153 Views)

Re: Retrieving the plugin path - C#

05-12-2014 07:11 PM in reply to: fergotrash

Hi,

 

This slould work: System.Reflection.Assembly.GetExecutingAssembly.Location

 

Gaston Nunez

*Expert Elite*
dgorsman
Posts: 5,515
Registered: ‎10-12-2006
Message 3 of 4 (117 Views)

Re: Retrieving the plugin path - C#

05-13-2014 08:01 AM in reply to: gasty1001

You might also want to try a more traditional route of using the registry, so that the data can be located on a personal network drive, common read-only network location, or similar place where a DLL might not be appropriate.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


New Member
fergotrash
Posts: 2
Registered: ‎05-12-2014
Message 4 of 4 (93 Views)

Re: Retrieving the plugin path - C#

05-14-2014 11:00 AM in reply to: dgorsman
Thank you both for the answer. Turns out the StreamReader accepts relative paths, so all I needed to do was ".\\folder\\". Kind regards, Fergo.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.