文件夹判断操作类 - C#小函数类推荐
创始人
2024-11-15 02:04:17
0

       此文记录的是关于文件夹操作的小函数。

/***      文件夹判断操作类      Austin Liu 刘恒辉     Project Manager and Software Designer      E-Mail: lzhdim@163.com     Blog:   http://lzhdim.cnblogs.com     Date:   2024-01-15 15:18:00  ***/  namespace Lzhdim.LPF.Utility {     using System;      using System.IO;      ///      /// 文件夹判断操作类     ///      public class DirDetermineUtil     {         ///          /// 判断目录和文件是否在同一个目录下         ///          /// 文件路径         /// 文件夹路径         /// true 在同一个文件夹;false 不在同一个文件夹         public static bool AreInSameDirectory(string filePath, string directoryPath)         {             // 获取文件的目录路径             string fileDirectory = Path.GetDirectoryName(filePath);              // 标准化路径,移除尾部的斜杠             fileDirectory = fileDirectory.TrimEnd(Path.DirectorySeparatorChar);             directoryPath = directoryPath.TrimEnd(Path.DirectorySeparatorChar);              // 比较两者是否相等             return string.Equals(fileDirectory, directoryPath, StringComparison.OrdinalIgnoreCase);         }          ///          /// 获取文件路径所在的目录名         ///          /// 文件路径         /// 文件所在目录         public static string GetFileLocatedDirName(string filePath)         {             string fileDir = Path.GetDirectoryName(filePath);              if (fileDir == null)             {                 //根目录                 return Path.GetPathRoot(filePath);             }              int lastIndex = fileDir.LastIndexOf("\\");              return fileDir.Substring(lastIndex + 1, fileDir.Length - lastIndex - 1);         }          ///          /// 判断当前文件是否在根目录         ///          /// 文件路径         /// true 在根目录;false 不在根目录         public static bool IsInLocatedRootDir(string filePath)         {             //如果没获取到路径的目录,则为根目录             return Path.GetDirectoryName(filePath) == null;         }     } } 

相关内容

热门资讯

曝光透视!wepoker手机插... 曝光透视!wepoker手机插件!记者揭秘辅助挂(有挂助手)-哔哩哔哩小薇(辅助器软件下载)致您一封...
一直以来!wpk俱乐部辅助器(... 一直以来!wpk俱乐部辅助器(透视)切实真的有辅助修改器(新版有挂)-哔哩哔哩1)wpk俱乐部辅助器...
开挂透视!wepoker免费透... 开挂透视!wepoker免费透视脚本!终于懂了辅助方法(存在有挂)-哔哩哔哩1)wepoker免费透...
针对!wepoker辅助器官方... 针对!wepoker辅助器官方(透视)一直存在有辅助安装(新版有挂)-哔哩哔哩1、玩家可以在wepo...
普及透视!wepoker辅助软... 普及透视!wepoker辅助软件视频!玩家必看秘籍辅助方法(有挂方法)-哔哩哔哩1、普及透视!wep...
截至目前!aapoker怎么设... 截至目前!aapoker怎么设置提高好牌几率(透视)都是是真的辅助辅助器(了解有挂)-哔哩哔哩1、a...
据相关数据显示!wepoker... 据相关数据显示!wepoker如何设置透视(透视)好像真的是有辅助平台(有挂解密)-哔哩哔哩1、完成...
详情透视!wepoker黑侠辅... 详情透视!wepoker黑侠辅助器正版下载!查到实测辅助辅助工具(有挂透明挂)-哔哩哔哩1、起透看视...
随着!德普之星辅助器app(透... 随着!德普之星辅助器app(透视)原来存在有辅助app(有挂实锤)-哔哩哔哩德普之星辅助器app破解...
解谜透视!wepoker怎么看... 解谜透视!wepoker怎么看牌型!盘点一款辅助技巧(有挂教学)-哔哩哔哩所有人都在同一条线上,像星...