using System;
using System.IO;
class Program
{
static void Main()
{
// 获取当前工作目录的路径
string currentPath = Directory.GetCurrentDirectory();
Console.WriteLine("当前工作目录: " + currentPath);
// 获取包含可执行文件的目录的路径
string exePath = AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine("包含可执行文件的目录: " + exePath);
}
}
Directory.GetCurrentDirectory()
:获取当前工作目录的路径。当前工作目录是指应用程序启动时所在的目录,或者通过代码更改后的目录。AppDomain.CurrentDomain.BaseDirectory
:获取包含可执行文件的目录路径。这个路径通常是应用程序的安装目录,不会随着当前工作目录的变化而变化。这两个方法都可以用来获取当前路径,具体使用哪个取决于你的需求。
上一篇:c# byte转int
下一篇:c# byte 转string
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站