実行ファイルのパスを取得する
絶対的(ライブラリ側からでも同じ値という意味)な実行ファイルのパスは、次の通り。
System.Reflection.Assembly.GetEntryAssembly().Location; // C:\aaa\bbb\ccc.exe System.Windows.Forms.Application.ExecutablePath; // C:\aaa\bbb\ccc.exe System.Windows.Forms.Application.StartupPath; // C:\aaa\bbb
※StartupPathプロパティだけは、ファイル名を含まない
また、ライブラリ自身のパスとなるとこれでOK。
System.Reflection.Assembly.GetExecutingAssembly().Location; // C:\aaa\bbb\ddd.dll
System.Windows.Forms のネームスペースを使用しているが、Windowsアプリケーション以外でも呼び出すことは可能でした。