diff --git a/Shared/Utils/FileUtils.cs b/Shared/Utils/FileUtils.cs index 76fe8db..816a260 100644 --- a/Shared/Utils/FileUtils.cs +++ b/Shared/Utils/FileUtils.cs @@ -38,16 +38,32 @@ public static class FileUtils { /// /// 删除文件。 /// - public static void Delete(string filePath) => File.Delete(PathUtils.ToLongPath(filePath)); + public static void Delete(string filePath) => + File.Delete(PathUtils.ToLongPath(filePath)); /// /// 确定指定的文件是否存在。 /// - public static bool Exists(string filePath) => File.Exists(PathUtils.ToLongPath(filePath)); + public static bool Exists(string filePath) => + File.Exists(PathUtils.ToLongPath(filePath)); /// /// 创建 对象。 /// - public static FileInfo GetInfo(string path) => new(PathUtils.ToLongPath(path)); + public static FileInfo GetInfo(string path) => + new(PathUtils.ToLongPath(path)); + /// + /// 打开该文件的只读 。 + /// + public static FileStream OpenRead(string filePath) => + new(PathUtils.ToLongPath(filePath), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + /// + /// 在指定路径创建文件,并打开 。 + /// + public static FileStream OpenCreate(string filePath) { + DirectoryUtils.Create(filePath, isFilePath: true); + return new(PathUtils.ToLongPath(filePath), FileMode.Create); + } }