C#日志把它写在当前程序目录下的txt文件中

2025-03-24 10:57:28
推荐回答(1个)
回答1:

MessageBox.Show(Environment.CurrentDirectory.ToString());//获取或设置当前工作目录的完全限定路径
MessageBox.Show(Application.StartupPath.ToString());//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称
MessageBox.Show(Directory.GetCurrentDirectory());//获取应用程序的当前工作目录
MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory);//获取基目录,它由程序集冲突解决程序用来探测程序集
MessageBox.Show(AppDomain.CurrentDomain.SetupInformation.ApplicationBase);//获取或设置包含该应用程序的目录的名称
MessageBox.Show(Process.GetCurrentProcess().ToString());

想在什么目录就在什么目录