How can I access the StartupPath of an Excel VSTO plugin?

1

I need to read a text file from the bin.

folder

I use Application.StartupPath of windows forms ,

but this one brings me another route.

    
asked by Javier 22.08.2018 в 16:56
source

2 answers

3

You could use the AppDomain.CurrentDomain.BaseDirectory method, this will return all the relative path of where the executable ( .exe ) of your application is.

    
answered by 22.08.2018 / 18:14
source
1

I already solved the problem in the following way:

Assembly assembly = Assembly.GetExecutingAssembly();
                string location = assembly.CodeBase;
                string fullPath = new Uri(location).LocalPath;
                string directoryPath = Path.GetDirectoryName(fullPath);
                StreamReader File = new StreamReader(directoryPath + "\BD.hys");
    
answered by 22.08.2018 в 20:58