文件夹判断操作类 - 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新号好一点吗(透视)竟然真的是有挂(详细辅助详细教程)1、下载好辅助软件之...
透视了解"wepok... 透视了解"wepoker辅助透视软件"详细辅助微扑克教程(确实是真的有挂)1、上手简单,内置详细流程...
第5分钟了解!对战互娱辅助,蜀... 第5分钟了解!对战互娱辅助,蜀友会通用辅助器(都是是有挂)1、构建自己的蜀友会通用辅助器辅助插件;2...
透视科技!hhpoker怎么开... 透视科技!hhpoker怎么开透视(透视)永久脚本辅助挂(详细辅助安装教程)1、下载好hhpoker...
透视私人局!hhpoker辅助... 透视私人局!hhpoker辅助挂(透视)果然真的有挂(详细辅助分享教程)辅助器中分为三种模型:软件透...
辅助透视"哈糖大菠萝... 辅助透视"哈糖大菠萝有挂吗5个常用方法"详细辅助插件教程(原来真的有挂)1、不需要AI权限,帮助你快...
9分钟了解!中至二人辅助器,玫... 9分钟了解!中至二人辅助器,玫瑰大厅辅助(一贯存在有挂)1、中至二人辅助器ai辅助优化,中至二人辅助...
透视中牌率!wepoker游戏... 透视中牌率!wepoker游戏安装教程(透视)永久脚本辅助方法(详细辅助揭秘教程)1、每一步都需要思...
透视辅助!wepoker新号好... 透视辅助!wepoker新号好一点吗(透视)都是是真的有挂(详细辅助软件教程);1、完成的残局,帮助...
透视软件"poker... 透视软件"poker红龙辅助"详细辅助细节方法(一直真的是有挂)1、全新机制【poker红龙辅助软件...