首页 > 编程语言 >C# 文件IO操作基本api

C# 文件IO操作基本api

时间:2022-10-09 22:01:33浏览次数:47  
标签:Console C# 456 api Combine IO Directory Path GetCurrentDirectory


// 获取当前目录的路径
var path = Directory.GetCurrentDirectory();
Console.WriteLine(path);

// 创建目录
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "stores","456","newDir"));

// 判断当前目录是否存在
bool doesDirectoryExists = Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "stores","456","newDir"));
Console.WriteLine(doesDirectoryExists);

// 创建文件
File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "greeting.txt"), "Hello World!");


标签:Console,C#,456,api,Combine,IO,Directory,Path,GetCurrentDirectory
From: https://blog.51cto.com/u_12836588/5741713

相关文章