I am trying to access the string which represents the path of the current directory my application has been placed in. I have an excel templates made in visual studio which needs to be populated by the names of files in the current directory (which the document have been placed) and its sub-directories. I cannot find anywhere a solution which actually works, I have found some attempts at a solution: get path for my .exe and various others , which do not work. I currently have the user enter the desired path but I would like to automatically find the path or find an alternative way to collect these names.
Directory of where Office solution has been placed
58 views Asked by user3812617 At
2
This depends upon how you're distributing your solution. Office add-ins and templates, when distributed through the standard ClickOnce mode, end up in a cryptically-named folder (inside another cryptically-named folder) that lives somewhere in AppData folder. You'll not be able to use the normal ways of getting the path of currently existing application, as they'll most probably return the path of EXCEL.EXE itself. This SO post provides a good way of getting the current folder in VSTO solutions.
Alternately you can consider using MSI for distributing your template/add-in. This is a longer path and has many caveats, but you'll end up installing your add-in/template in Program Files folder.