C#编程-30:创建文件或文件夹

1、合并文件夹路径和文件名:

Path.Combine(folderName, fileName);


2、创建文件夹:

Directory.CreateDirectory(path);


3、创建文件:

File.Create(filePath);


4、判断文件是否存在:

File.Exists(path);


5、判断文件夹是否存在:

Directory.Exists(path);


参考链接:

https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/file-system/how-to-create-a-file-or-folder

上一篇:数据结构实验之——栈的应用:算数表达式求值问题(不带括号情况)


下一篇:C#编程-29:循环访问目录树