判断一个字符串是否是目录

318 318
C#
sam
sam 2024-08-05 15:10:59

代码如下

        /// <summary>
        /// 判断一个字符串是否是目录
        /// </summary>
        /// <returns></returns>
        public static Boolean IsDir(string dir)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(dir);

                if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Write(ex.Message);
            }

            return false;
        }


回帖
  • 消灭零回复