ref: 将 MeloongCore 的 WPF 部分独立到另一个子工程

This commit is contained in:
龙腾猫跃 committed 2026-04-28 21:40:00 +08:00
1 parent 1036bc9642
commit 1910e96567
13 files changed
+103 -29

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
namespace MeloongCore;
public static class DirectoryUtils {
/// <summary>
/// 确保路径以 / 或 \ 结尾。
/// </summary>
public static string ToDirectoryFormat(string folder) => IsDirectoryFormat(folder) ? folder : folder + Path.DirectorySeparatorChar;
/// <summary>
/// 检查路径是否以 / 或 \ 结尾。
/// </summary>
public static bool IsDirectoryFormat(string path) => path.EndsWithF("/") || path.EndsWithF("\\");
/// <summary>
/// 创建文件夹,或文件所在的文件夹。
/// 支持长路径。
/// 文件夹已存在时不会抛出异常。
/// </summary>
public static void Create(string path, bool isFilePath = false) {
path = FileUtils.ShortenPath(path);
if (isFilePath) path = Path.GetDirectoryName(path);
Directory.CreateDirectory(path);
}
}