文件夹判断操作类 - 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;         }     } } 

相关内容

热门资讯

透视计算!hhpoker辅助靠... 透视计算!hhpoker辅助靠谱吗,hh poker辅助有用吗,必赢方法(有挂介绍);1、玩家可以在...
透视好牌!wepoker私局代... 透视好牌!wepoker私局代打,wepoker分析(一直是有挂)1、进入到wepoker私局代打黑...
透视挂透视!aapoker怎么... 透视挂透视!aapoker怎么开辅助器,aapoker真的假的,解密教程(有挂方法)在进入aapok...
透视有挂!hhpoker破解工... 透视有挂!hhpoker破解工具,hhpoker德州作弊,攻略教程(有挂揭秘)暗藏猫腻,小编详细说明...
透视神器!wepoker私人局... 透视神器!wepoker私人局有透视吗,we poker辅助器下载(切实真的有挂);1)wepoke...
透视神器!aa poker透视... 透视神器!aa poker透视软件,aapoker怎么选牌,教你教程(有挂规律)aa poker透视...
透视新版!hhpoker脚本下... 透视新版!hhpoker脚本下载,hhpoker是真的假的,wpk教程(有挂解说)小薇(透视辅助)致...
辅助透视!wepoker轻量版... 辅助透视!wepoker轻量版有透视吗,wepoker辅助器如何使用(竟然真的有挂);1、每一步都需...
透视教程!aapoker透视脚... 透视教程!aapoker透视脚本入口,aapoker免费透视脚本,辅助教程(有挂详情)1、构建自己的...
透视规律!德州hhpoker是... 透视规律!德州hhpoker是真的吗,hhpoker透视脚本视频,安装教程(有挂揭秘);1、这是跨平...