Console 路徑
namespace MVATwentyQuestions { class Program { static void Main(string[] args) { // 利用 Reflection 來進行 string ConsolePath = System.Reflection.Assembly.GetExecutingAssembly().Location; Console.WriteLine(System.IO.Path.GetDirectoryName(ConsolePath)); } } }Winform 路徑
private void btnPath_Click(object sender, EventArgs e) { string WinformPath = Application.StartupPath; MessageBox.Show(WinformPath); }
沒有留言:
張貼留言