Retrieving the plugin path - C#

Retrieving the plugin path - C#

Fergobirck
Explorer Explorer
1,648 Views
3 Replies
Message 1 of 4

Retrieving the plugin path - C#

Fergobirck
Explorer
Explorer

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.

0 Likes
1,649 Views
3 Replies
Replies (3)
Message 2 of 4

hgasty1001
Advisor
Advisor

Hi,

 

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

 

Gaston Nunez

0 Likes
Message 3 of 4

dgorsman
Consultant
Consultant

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.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 4 of 4

Fergobirck
Explorer
Explorer
Thank you both for the answer. Turns out the StreamReader accepts relative paths, so all I needed to do was ".\\folder\\". Kind regards, Fergo.
0 Likes