[Mono-list] Implementation of
'System.Runtime.InteropServices.RuntimeEnvironment.cs'
Gonzalo Paniagua Javier
gonzalo@ximian.com
25 Apr 2003 01:38:29 +0200
You do this:
> public static string GetRuntimeDirectory()
> {
> string result = String.Empty;
> Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
>
> foreach (Assembly a in assemblies)
> {
> string codebase = a.Location;
> if (codebase.EndsWith ("corlib.dll"))
> {
> result = codebase.Substring (0, codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
> }
> }
>
> return result;
> }
And there's a simpler way:
public static string GetRuntimeDirectory ()
{
return Path.GetDirectoryName (typeof (int).Assembly.Location);
}
-Gonzalo