How to detect current executable file name?
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 1 11:22:58 PDT 2014
On Monday, 18 February 2013 at 03:28:59 UTC, eGust wrote:
> I need to locate the directory of current executable file, but
> I can't find how to do that in Phobos. I tried
> core.runtime.Runtime.args[0], but failed. Is there a standard
> method of Phobos to do that? I only know the way of Windows
> (GetModuleFileName), but I think as a common task there should
> be a platform-independent way to get it in the standard library.
import std.stdio;
import std.file : thisExePath;
import std.path : dirName;
void main(string[] args)
{
writeln(dirName(thisExePath()));
}
More information about the Digitalmars-d-learn
mailing list