简体   繁体   中英

CurrentDirectory and Excel-DNA

I'm using Excel-DNA and debbuging ac# code that is used in Excel by attaching the process to VS17.

My issue is that i don't understand why while debugging, my project's current directory switches to C:\\Users\\userX\\Documents:

string test = Directory.GetCurrentDirectory(); // C:\Users\userX\Documents

which is a directory not used at all in all the classes in my project and poses an issue as i'm using an app.Config to read some static data (which hence won't be retrieved):

string staticData = ConfigurationManager.AppSettings["data"];

I'm wondering how i could overcome this issue ?

Many thanks for your help.

It's Excel setting the current directory.

You can retrieve the full path to your Excel-DNA add-in with a call to ExcelDnaUtil.XllPath .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM