NewbieDude

hi there,

how do I get the application directory. that is, the directory of the running application as a string



Re: Visual C# General How do I get the application directory

ctusch

With Application.StartupPath for example.




Re: Visual C# General How do I get the application directory

NewbieDude

I need to know the directory of the code and the solution files, not Visual Studio





Re: Visual C# General How do I get the application directory

Adriaan W

Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingPath())



Re: Visual C# General How do I get the application directory

NewbieDude

GetExecutingPath() does not exist in the Assembly class





Re: Visual C# General How do I get the application directory

Adriaan W

sorry

getExecutingAssembly().Location

if you use the intellisense.. you could have found it




Re: Visual C# General How do I get the application directory

NewbieDude

tks but i code in notepad only





Re: Visual C# General How do I get the application directory

Adriaan W

I'm also a person who likes notepad.. but coding .Net in Visual Studio is so much easier, faster, error-preventing, ...

Why you are not using an editor like Visual Studio




Re: Visual C# General How do I get the application directory

CalvinR

Screw coding in notepad use a real programmers tool like VI (or VIM), it's much much much much (I could go on forever) better then notepad.

It has autocomplete, undo/redo, hell i could go on and on and on.
It has a steep learning curve because it is a state based editor but if you hate visual studio like me this would be perfect for you.

http://www.vim.org/








Re: Visual C# General How do I get the application directory

CalvinR

Also for intellisense it would be better if you don't rely on it, it's nice to have but ultimatly it will make you a poorer programmer, it's better to actually look at the documentation for the objects/functions that you are using then to pick and choose through the intellisense lists. Then you will actually really understand what you are doing. Plus what would happen if you ever had to program with a language that doesn't use intellisense You would have a very hard time adjusting to it.





Re: Visual C# General How do I get the application directory

TilakGopi

Hi ,

Just check the following code snippet

----------------------------------------------------------

String strAppPath = Application.ExecutablePath;

String[] tokens = strAppPath.Split(new char[] { '.' });

String strFolderPath = tokens[0];

int nPos = tokens[0].LastIndexOf("\\")+1;

String FileName = tokens[0].Substring(nPos);

--------------------------------------------------------------------------------

Now strAppPath contains - complete exe path.

tokens[0] , strFolderPath both contain - complete folder path containing the exe.

strFileName contains - the exe file name(with out extension).

tokens[1] contains - the extension- exe.

Hope u r done.

Cheers,

Ch.T.Gopi Kumar.