当前位置: 首页>>代码示例>>C#>>正文


C# FileAttributes.HasFlag方法代码示例

本文整理汇总了C#中FileAttributes.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# FileAttributes.HasFlag方法的具体用法?C# FileAttributes.HasFlag怎么用?C# FileAttributes.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileAttributes的用法示例。


在下文中一共展示了FileAttributes.HasFlag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFolder

 public override void CreateFolder(string folder, FileAttributes attributes) {
     folder = folder.Replace('\\', '/');
     PutObjectRequest request = new PutObjectRequest() {
         BucketName = this.bucket,
         Key = this.prefix + folder + '/',
         ContentBody = "",
         StorageClass = this.storageClass,
     };
     this.withHandling(() => {
         request.AddHeader("x-amz-meta-hidden", attributes.HasFlag(FileAttributes.Hidden) ? "true" : "false");
         request.AddHeader("x-amz-meta-archive", attributes.HasFlag(FileAttributes.Archive) ? "true" : "false");
         request.AddHeader("x-amz-meta-not-index", attributes.HasFlag(FileAttributes.NotContentIndexed) ? "true" : "false");
         this.client.PutObject(request);
     }, folder);
     this.folders.Add(folder);
 }
开发者ID:modulexcite,项目名称:backer_upper,代码行数:16,代码来源:S3Backend.cs

示例2: AttributeBreakdown

        public static AttributeFlags AttributeBreakdown(FileAttributes flags)
        {
            AttributeFlags attributes = new AttributeFlags();

            if (flags.HasFlag(FileAttributes.Normal))
                attributes.Normal = true;

            if (flags.HasFlag(FileAttributes.Archive))
                attributes.Archive = true;

            if (flags.HasFlag(FileAttributes.Compressed))
                attributes.Compressed = true;

            if (flags.HasFlag(FileAttributes.Device))
                attributes.Device = true;

            if (flags.HasFlag(FileAttributes.Directory))
                attributes.Directory = true;

            if (flags.HasFlag(FileAttributes.Encrypted))
                attributes.Encrypted = true;

            if (flags.HasFlag(FileAttributes.Hidden))
                attributes.Hidden = true;

            if (flags.HasFlag(FileAttributes.IntegrityStream))
                attributes.IntegrityStream = true;

            if (flags.HasFlag(FileAttributes.NoScrubData))
                attributes.NoScrubData = true;

            if (flags.HasFlag(FileAttributes.NotContentIndexed))
                attributes.NotContentIndexed = true;

            if (flags.HasFlag(FileAttributes.Offline))
                attributes.Offline = true;

            if (flags.HasFlag(FileAttributes.ReadOnly))
                attributes.ReadOnly = true;

            if (flags.HasFlag(FileAttributes.ReparsePoint))
                attributes.ReparsePoint = true;

            if (flags.HasFlag(FileAttributes.SparseFile))
                attributes.SparseFile = true;

            if (flags.HasFlag(FileAttributes.System))
                attributes.System = true;

            if (flags.HasFlag(FileAttributes.Temporary))
                attributes.Temporary = true;

            return attributes;
        }
开发者ID:CDillinger,项目名称:AttributeEditor,代码行数:54,代码来源:File.cs

示例3: GetMode

 private static string GetMode(FileAttributes attr)
 {
     var sb = new StringBuilder();
     sb.Append(attr.HasFlag(FileAttributes.Directory) ? "d" : "-");
     sb.Append(attr.HasFlag(FileAttributes.Archive) ? "a" : "-");
     sb.Append(attr.HasFlag(FileAttributes.ReadOnly) ? "r" : "-");
     sb.Append(attr.HasFlag(FileAttributes.Hidden) ? "h" : "-");
     sb.Append(attr.HasFlag(FileAttributes.System) ? "s" : "-");
     sb.Append(attr.HasFlag(FileAttributes.ReparsePoint) ? "l" : "-");
     return sb.ToString();
 }
开发者ID:skazantsev,项目名称:Servant,代码行数:11,代码来源:FileSystemInfoModel.cs

示例4: LogFSActionError

        DokanError IDokanOperations.SetFileAttributes(string fileName, FileAttributes attributes, DokanFileInfo info)
        {
            LogFSActionError("SetFileAttr", fileName, (SftpContext)info.Context, "Attrs:{0}", attributes);

            //get actual attributes
            string path = GetUnixPath(fileName);
            SftpFileAttributes currentattr = GetAttributes(path);

            //rules for changes:
            bool rightsupdate = false;
                if (attributes.HasFlag(FileAttributes.Archive) && !GroupRightsSameAsOwner(currentattr))
                {
                    LogFSActionSuccess("SetFileAttr", fileName, (SftpContext)info.Context, "Setting group rights to owner");
                    //Archive goes ON, rights of group same as owner:
                    currentattr.GroupCanWrite = currentattr.OwnerCanWrite;
                    currentattr.GroupCanExecute = currentattr.OwnerCanExecute;
                    currentattr.GroupCanRead = currentattr.OwnerCanRead;
                    rightsupdate = true;
                }
                if (!attributes.HasFlag(FileAttributes.Archive) && GroupRightsSameAsOwner(currentattr))
                {
                    LogFSActionSuccess("SetFileAttr", fileName, (SftpContext)info.Context, "Setting group rights to others");
                    //Archive goes OFF, rights of group same as others:
                    currentattr.GroupCanWrite = currentattr.OthersCanWrite;
                    currentattr.GroupCanExecute = currentattr.OthersCanExecute;
                    currentattr.GroupCanRead = currentattr.OthersCanRead;
                    rightsupdate = true;
                }

            //apply new settings:
            if (rightsupdate)
            {
                //apply and reset cache
                try
                {
                    _sftpSession.RequestSetStat(GetUnixPath(fileName), currentattr);
                }
                catch(SftpPermissionDeniedException e)
                {
                    return DokanError.ErrorAccessDenied;
                }
                CacheReset(path);
                CacheResetParent(path); //parent cache need reset also

                //if context exists, update new rights manually is needed
                SftpContext context = (SftpContext)info.Context;
                if (info.Context != null)
                {
                    context.Attributes.GroupCanWrite = currentattr.GroupCanWrite;
                    context.Attributes.GroupCanExecute = currentattr.GroupCanExecute;
                    context.Attributes.GroupCanRead = currentattr.GroupCanRead;
                }
            }

            return DokanError.ErrorSuccess;
        }
开发者ID:cpascal,项目名称:win-sshfs,代码行数:56,代码来源:SftpFilesystem.cs

示例5: IsDirectoryAllowed

 public bool IsDirectoryAllowed(string relativePath, FileAttributes attributes) {
     return !attributes.HasFlag(FileAttributes.Hidden);
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:3,代码来源:RMsBuildFileSystemFilter.cs

示例6: IsFileAllowed

 public bool IsFileAllowed(string relativePath, FileAttributes attributes) {
     return !attributes.HasFlag(FileAttributes.Hidden)
         && !HasExtension(relativePath, ".user", RContentTypeDefinition.VsRProjectExtension, ".sln");
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:4,代码来源:RMsBuildFileSystemFilter.cs

示例7: IsSymbolicLink

 public bool IsSymbolicLink( FileAttributes fileAttributes )
 {
     var isError = (int)fileAttributes == -1;
     var isSymbolicLink = fileAttributes.HasFlag( FileAttributes.ReparsePoint );
     return !isError && isSymbolicLink;
 }
开发者ID:XElementSoftware,项目名称:CloudSyncHelper,代码行数:6,代码来源:SymbolicLinkHelper.cs

示例8: CreateFile

        public override bool CreateFile(string file, string source, DateTime lastModified, string fileMD5, FileAttributes attributes, bool reportProgress=true) {
            file = file.Replace('\\', '/');
            string key = this.prefix + file;

            if (this.files.Contains(file) && this.FileMD5(file) == fileMD5) {
                return false;
            }

            PutObjectRequest putRequest = new PutObjectRequest() {
                BucketName = this.bucket,
                FilePath = source,
                Key = key,
                Timeout = -1,
                CannedACL = S3CannedACL.Private,
                StorageClass = this.storageClass,
            };
            if (reportProgress)
                putRequest.PutObjectProgressEvent += new EventHandler<PutObjectProgressArgs>(putRequest_PutObjectProgressEvent);
            this.withHandling(() => {
                putRequest.AddHeader("x-amz-meta-md5", fileMD5);
                putRequest.AddHeader("x-amz-meta-hidden", attributes.HasFlag(FileAttributes.Hidden) ? "true" : "false");
                putRequest.AddHeader("x-amz-meta-archive", attributes.HasFlag(FileAttributes.Archive) ? "true" : "false");
                putRequest.AddHeader("x-amz-meta-not-index", attributes.HasFlag(FileAttributes.NotContentIndexed) ? "true" : "false");
                this.client.PutObject(putRequest);
            }, file);
            this.files.Add(file);
            return true;
        }
开发者ID:modulexcite,项目名称:backer_upper,代码行数:28,代码来源:S3Backend.cs

示例9: IsFileAllowed

 public bool IsFileAllowed(string relativePath, FileAttributes attributes) {
     return !attributes.HasFlag(FileAttributes.Hidden)
         && !HasExtension(relativePath, ".user", ".rxproj", ".sln");
 }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:4,代码来源:RMsBuildFileSystemFilter.cs


注:本文中的FileAttributes.HasFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。