Tags: | Categories: Code Snippets Posted by Vitaly Zayko on 12/23/2009 4:58 PM | Comments (0)

There is an another way how to get path to a running assembly from itself besides I mentioned here. Use this simple snippet:

string[] cmd = Environment.GetCommandLineArgs();
string path_to_assembly = cmd[0];
/* cmd[1] and above contains command line arguments is any */

Resulting array is at least one element length or longer. First element of this array always contains path to the assembly. As a side effect – you can get command line params beginning from second element.

Unfortunately doesn’t work in .NET Compact Framework.

Technorati Tags: ,
Comments are closed