Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Bin Path?

Tags:

c#

.net

I need to the the bin path of the executing assembly. How do you get it? I have a folder Plugins in the Bin/Debug and I need to get the location

like image 681
user9969 Avatar asked Aug 11 '10 19:08

user9969


People also ask

How do I find my bin PATH?

The bin directory in Unix-like systems contains the programs of the system and the installed ones, but in Windows, system programs are located in C:\Windows\System32 and installed ones are likely located in C:\Program Files .

What is a bin directory PATH?

This is a list of folders that Windows searches, in order, when it can't find a dll (say) in the current directory. So if you want to have a dll used by more than one program you could put it in a location already on the PATH or add a new folder to the PATH. Copy link CC BY-SA 2.5.


2 Answers

You could do this

    Assembly asm = Assembly.GetExecutingAssembly();     string path = System.IO.Path.GetDirectoryName(asm.Location); 
like image 39
etoisarobot Avatar answered Nov 15 '22 22:11

etoisarobot


Here is how you get the execution path of the application:

var path = System.IO.Path.GetDirectoryName(        System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); 

MSDN has a full reference on how to determine the Executing Application's Path.

Note that the value in path will be in the form of file:\c:\path\to\bin\folder, so before using the path you may need to strip the file:\ off the front. E.g.:

path = path.Substring(6); 
like image 50
kemiller2002 Avatar answered Nov 16 '22 00:11

kemiller2002