Community
Showing results for 
Search instead for 
Do you mean 
Reply

Plugin

New Member
Posts: 7
Country: United States

Plugin

I have written a plugin that reads an xml file to gather some user defined properties. I locate the xml file with the following line:

 

string strConfigDataFile = Path.Combine(Environment.CurrentDirectory, @"Plugins\ConfigData.xml");

 

This works fine as long as ACT is started from it's normal location e.g. C:\Program Files\ACT\Act for Windows.

 

However, we have a client that is starting ACT! by placing the PAD file on the desktop, and double clicking of the PAD file.  When it starts this way the plugin creates an exception that the file cannot be found.  Upon further investigation, Environment.CurrentDirectory is returning  "C:\Documents and Settings\My User\Desktop", which is where the PAD file lives. 

 

I could place the config file anywhere, such as the system folder and that should resolve the issue.

 

My question is this.  Obviously ACT! is able to determine the Plugins folder regardless of how ACT! is started.  How can I capture this path?

 

 

Employee
Posts: 33
Country: USA

Re: Plugin

Try using this to get the base directory for ACT! and append what you need:

 

AppDomain.CurrentDomain.BaseDirectory

Tim Faust
ACT! R&D
New Member
Posts: 9
Country: United States

Re: Plugin

Another option is to use:

 

 

System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); string path = asm.Location + ".config";

 

If your plugin is named "MyPlugin.dll" then this results in a full path to a config file named "<Plugin Path>\MyPlugin.dll.config". There are a few other options for getting different assemblies. I actually use GetAssembly( this.GetType() ), but I believe that GetExecutingAssembly( ) should accomplish the same thing.

 

/cm