(原創) 如何得知目前執行檔所在的目錄? (.NET) (C#)
C#
/*
(C) OOMusou 2007 http://oomusou.cnblogs.com
Filename : GetCurrentDirectory.cs
Compiler : Visual Studio 2005 / C# 2.0
Description : Demo how to get current directory of executable
Release : 09/29/2007 1.0
*/
using System;
using System.IO;
class Client {
static void Main() {
string path = Directory.GetCurrentDirectory();
Console.WriteLine(path);
}
}
(C) OOMusou 2007 http://oomusou.cnblogs.com
Filename : GetCurrentDirectory.cs
Compiler : Visual Studio 2005 / C# 2.0
Description : Demo how to get current directory of executable
Release : 09/29/2007 1.0
*/
using System;
using System.IO;
class Client {
static void Main() {
string path = Directory.GetCurrentDirectory();
Console.WriteLine(path);
}
}
執行結果
D:\__Clare\CSharp\CSharpLab\bin\Release