using System;
class Program
{
static void Main()
{
// 获取当前工作目录
string currentDirectory = System.IO.Directory.GetCurrentDirectory();
Console.WriteLine("当前工作目录: " + currentDirectory);
// 获取包含可执行文件的目录
string exeDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine("包含可执行文件的目录: " + exeDirectory);
}
}
获取当前工作目录:
System.IO.Directory.GetCurrentDirectory():返回当前工作目录的路径。当前工作目录是指程序启动时所在的目录,或者通过代码更改后的目录。获取包含可执行文件的目录:
System.AppDomain.CurrentDomain.BaseDirectory:返回包含应用程序的可执行文件的目录。这个路径通常是程序启动时所在的目录,不会被后续代码更改。这两个方法都可以用来获取当前路径,但它们返回的路径可能不同,具体取决于程序的运行环境和配置。
上一篇:c#连接oracle数据库
下一篇:c# progressbar
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站