代码如下
/// <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; }