Exemplo n.º 1
0
        /// <summary>
        /// 取消文件的只读设置
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static void ClearReadonly(string filePath)
        {
            FileAttributes attributes = RetryFile.GetAttributes(filePath);

            if (attributes.HasFlag(FileAttributes.ReadOnly) == false)
            {
                return;
            }

            // 清除只读属性
            attributes &= ~FileAttributes.ReadOnly;

            CreateRetry().Run(() => {
                File.SetAttributes(filePath, attributes);
                return(1);
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// 判断文件是否为隐藏文件
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public static bool IsHidden(string filePath)
 {
     return(RetryFile.GetAttributes(filePath).HasFlag(FileAttributes.Hidden));
 }