方法一:

System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly();
string baseDir = System.IO.Path.GetDirectoryName(a.Location);

方法二:

string baseDir = Application.ExecutablePath;
baseDir = baseDir.Remove( baseDir.LastIndexOf('\\'));  // 去掉執行檔部份

參考資料:http://bytes.com/topic/c-sharp/answers/252592-how-can-i-get-my-exe-path

By closer

發表迴響