• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FileAttributes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WriteLicense

        internal void WriteLicense(string path, string netsealId, LicenseFile licenseFile, FileAttributes attributes = 0)
        {
            if (string.IsNullOrWhiteSpace(path))
                throw new Exception("path");

            InternalWriteLicense(path, netsealId, licenseFile, attributes);
        }
开发者ID:abazad,项目名称:NetSeal-Helper,代码行数:7,代码来源:LicenseWriter.cs


示例2: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            FileInfo fi = new FileInfo(this.openFileDialog1.FileName);
            FileAttributes fa = new FileAttributes();

            foreach(object o in this.chkListFileAttributes.CheckedItems)
            {
                fa = fa | (FileAttributes)(Enum)o;
            }

            try
            {
                if(fi.IsReadOnly) fi.IsReadOnly = false;
                fi.CreationTime = DateTime.Parse(this.txtCreationTime.Text);
                fi.LastAccessTime = DateTime.Parse(this.txtLastAccessTime.Text);
                fi.LastWriteTime = DateTime.Parse(this.txtLastWriteTime.Text);

                fi.Attributes = fa;
                getFileInfo(fi);

            }catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:joshuaphendrix,项目名称:FilePeeker,代码行数:25,代码来源:frmFilePeeker.cs


示例3: Node

 public Node(string name, FileAttributes attrs)
 {
     Attributes = attrs;
     Name = name;
     Parents = new HashSet<Node>();
     Contains = new HashSet<Node>();
 }
开发者ID:CosminLazar,项目名称:SystemWrapper,代码行数:7,代码来源:Node.cs


示例4: FromFileAttribs

        private static string FromFileAttribs(FileAttributes attribs)
        {
            var str = new StringBuilder(9);

            if ((attribs & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                str.Append('R');
            if ((attribs & FileAttributes.Archive) == FileAttributes.Archive)
                str.Append('A');
            if ((attribs & FileAttributes.System) == FileAttributes.System)
                str.Append('S');
            if ((attribs & FileAttributes.Hidden) == FileAttributes.Hidden)
                str.Append('H');
            if ((attribs & FileAttributes.Normal) == FileAttributes.Normal)
                str.Append('N');
            if ((attribs & FileAttributes.Directory) == FileAttributes.Directory)
                str.Append('D');
            if ((attribs & FileAttributes.Offline) == FileAttributes.Offline)
                str.Append('O');
            if ((attribs & FileAttributes.Compressed) == FileAttributes.Compressed)
                str.Append('C');
            if ((attribs & FileAttributes.Temporary) == FileAttributes.Temporary)
                str.Append('T');

            return str.ToString();
        }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:25,代码来源:Conversions.cs


示例5: GetAttributeLetter

 private static string GetAttributeLetter(FileAttributes fileAttributes, FileAttributes attributeToSearch, string attributeLetter)
 {
     if ((fileAttributes & attributeToSearch) == attributeToSearch)
         return attributeLetter;
     else
         return "-";
 }
开发者ID:almx,项目名称:ExRep,代码行数:7,代码来源:AttributeStringCreator.cs


示例6: Pack

        public static long Pack(FileAttributes fa)
        {
            long ret = 0;
            if ((fa & FileAttributes.Directory) > 0) ret |= Directory;

            return ret;
        }
开发者ID:drme,项目名称:disks-db,代码行数:7,代码来源:FileInfo.cs


示例7: FileTreeNodeProperty

 public FileTreeNodeProperty(string _name, FileTreeNodeType _type, string _fullPath, FileAttributes _fileSystemAttributes)
 {
     name__ = _name;
     type__ = _type;
     fullPath__ = _fullPath;
     fileSystemAttributes__ = _fileSystemAttributes;
 }
开发者ID:daxnet,项目名称:guluwin,代码行数:7,代码来源:FileTreeNodeProperty.cs


示例8: CreateFile

        public static Stream CreateFile(
            string fileName, FileAccess fileAccess, FileShare fileShare, FileMode fileMode, FileAttributes flags)
        {
            // TODO: This is not quite right, but it's close.
            //
            var nativeAccess = fileAccess;
            if ((nativeAccess & FileAccess.Read) != 0)
            {
                nativeAccess &= ~FileAccess.Read;
                nativeAccess |= (FileAccess)GENERIC_READ;
            }
            if ((nativeAccess & FileAccess.Write) != 0)
            {
                nativeAccess &= ~FileAccess.Write;
                nativeAccess |= (FileAccess)GENERIC_WRITE;
            }

            var handle = _CreateFile(fileName, nativeAccess, fileShare, IntPtr.Zero, fileMode, flags, IntPtr.Zero);
            if (handle.IsInvalid)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            return new SimpleFileStream(handle);
        }
开发者ID:DeCarabas,项目名称:sudo,代码行数:25,代码来源:NativeMethods.cs


示例9: PathAlreadyExistsAsDirectory

 public void PathAlreadyExistsAsDirectory(FileAttributes attributes)
 {
     string path = GetTestFileName();
     DirectoryInfo testDir = Directory.CreateDirectory(Path.Combine(TestDirectory, path));
     testDir.Attributes = attributes;
     Assert.Equal(testDir.FullName, new DirectoryInfo(TestDirectory).CreateSubdirectory(path).FullName);
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:CreateSubdirectory.cs


示例10: UnixInvalidAttributes

 public void UnixInvalidAttributes(FileAttributes attr)
 {
     var path = GetTestFilePath();
     File.Create(path).Dispose();
     Set(path, attr);
     Assert.Equal(FileAttributes.Normal, Get(path));
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:GetSetAttributes.cs


示例11: EnumerateChildrenInternal

        internal static IEnumerable<IFileSystemInformation> EnumerateChildrenInternal(
            string directory,
            ChildType childType,
            string searchPattern,
            System.IO.SearchOption searchOption,
            FileAttributes excludeAttributes,
            IFileService fileService)
        {
            // We want to be able to see all files as we recurse and open new find handles (that might be over MAX_PATH).
            // We've already normalized our base directory.
            string extendedDirectory = Paths.AddExtendedPrefix(directory);

            // The assertion here is that we want to find files that match the desired pattern in all subdirectories, even if the
            // subdirectories themselves don't match the pattern. That requires two passes to avoid overallocating for directories
            // with a large number of files.

            // First look for items that match the given search pattern in the current directory
            using (FindOperation findOperation = new FindOperation(Paths.Combine(extendedDirectory, searchPattern)))
            {
                FindResult findResult;
                while ((findResult = findOperation.GetNextResult()) != null)
                {
                    bool isDirectory = (findResult.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == FileAttributes.FILE_ATTRIBUTE_DIRECTORY;

                    if ((findResult.Attributes & excludeAttributes) == 0
                        && findResult.FileName != "."
                        && findResult.FileName != ".."
                        && ((isDirectory && childType == ChildType.Directory)
                            || (!isDirectory && childType == ChildType.File)))
                    {
                        yield return FileSystemInformation.Create(findResult, directory, fileService);
                    }
                }
            }

            if (searchOption != System.IO.SearchOption.AllDirectories) yield break;

            // Now recurse into each subdirectory
            using (FindOperation findOperation = new FindOperation(Paths.Combine(extendedDirectory, "*"), directoriesOnly: true))
            {
                FindResult findResult;
                while ((findResult = findOperation.GetNextResult()) != null)
                {
                    // Unfortunately there is no guarantee that the API will return only directories even if we ask for it
                    bool isDirectory = (findResult.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == FileAttributes.FILE_ATTRIBUTE_DIRECTORY;

                    if ((findResult.Attributes & excludeAttributes) == 0
                        && isDirectory
                        && findResult.FileName != "."
                        && findResult.FileName != "..")
                    {
                        foreach (var child in EnumerateChildrenInternal(Paths.Combine(directory, findResult.FileName), childType, searchPattern,
                            searchOption, excludeAttributes, fileService))
                        {
                            yield return child;
                        }
                    }
                }
            }
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:60,代码来源:DirectoryInformation.cs


示例12: WriteAllBytes

 public void WriteAllBytes(string path, byte[] bytes, FileAttributes attributes)
 {
     if (File.Exists(path))
         File.SetAttributes(path, FileAttributes.Normal);
     File.WriteAllBytes(path, bytes);
     File.SetAttributes(path, attributes);
 }
开发者ID:Xarlot,项目名称:DXVcs2Git,代码行数:7,代码来源:FileSystem.cs


示例13: AddTree

        public static void AddTree(DirNode dirNode, string dirPrefix, string filePrefix, int width, int depth, int fileSizeInKB, FileAttributes? fa = null, DateTime? lmt = null)
        {
            for (int i = 0; i < width; ++i)
            {
                string fileName = i == 0 ? filePrefix : filePrefix + "_" + i;
                FileNode fileNode = new FileNode(fileName)
                {
                    SizeInByte = 1024L * fileSizeInKB,
                    FileAttr = fa,
                    LastModifiedTime = lmt,
                };

                dirNode.AddFileNode(fileNode);
            }

            if (depth > 0)
            {
                for (int i = 0; i < width; ++i)
                {
                    string dirName = i == 0 ? dirPrefix : dirPrefix + "_" + i;
                    DirNode subDirNode = dirNode.GetDirNode(dirName);
                    if (subDirNode == null)
                    {
                        subDirNode = new DirNode(dirName);
                        dirNode.AddDirNode(subDirNode);
                    }

                    DMLibDataHelper.AddTree(subDirNode, dirPrefix, filePrefix, width, depth - 1, fileSizeInKB, fa, lmt: lmt);
                }
            }
        }
开发者ID:ggais,项目名称:azure-storage-net-data-movement,代码行数:31,代码来源:DMLibDataHelper.cs


示例14: LoadFileConfiguration

 public LoadFileConfiguration(string sourceFile, string targetFile,
     FileAttributes targetFileAttributes = FileAttributes.Normal)
 {
     SourceFile = sourceFile;
     TargetFile = targetFile;
     TargetFileAttributes = targetFileAttributes;
 }
开发者ID:MisterHoker,项目名称:NetworkLibrary,代码行数:7,代码来源:LoadFileConfiguration.cs


示例15: CreateFile

        public DokanError CreateFile(string fileName, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info)
        {
            info.DeleteOnClose = (options & FileOptions.DeleteOnClose) != 0;
            //Console.WriteLine("CreateFile: {0}, mode = {1}", fileName, mode);

            if (fileName == "\\")
            {
                return DokanError.ErrorSuccess;
            }

            Directory dir = new Directory(Util.GetPathDirectory(fileName));
            if (!dir.Exists())
            {
                return DokanError.ErrorPathNotFound;
            }

            String name = Util.GetPathFileName(fileName);

            if (name.Length == 0)
            {
                return DokanError.ErrorInvalidName;
            }
            if (name.IndexOfAny(Path.GetInvalidFileNameChars()) > -1)
            {
                return DokanError.ErrorInvalidName;
            }

            // dokan API 要求在目标文件是目录时候,设置 info.IsDirectory = true
            if (dir.Contains(name) && (dir.GetItemInfo(name).attribute & FileAttributes.Directory) != 0)
            {
                info.IsDirectory = true;
                return DokanError.ErrorSuccess;
            }

            try
            {
                File f = new File(fileName, mode);
                f.flagDeleteOnClose = info.DeleteOnClose;
                info.Context = f;
            }
            catch (FileNotFoundException)
            {
                return DokanError.ErrorFileNotFound;
            }
            catch (IOException)
            {
                return DokanError.ErrorAlreadyExists;
            }
            catch (NotImplementedException)
            {
                return DokanError.ErrorAccessDenied;
            }
            catch (Exception)
            {
                return DokanError.ErrorError;
            }

            return DokanError.ErrorSuccess;
        }
开发者ID:WishSummer,项目名称:FS,代码行数:59,代码来源:FSDrive.cs


示例16: WindowsAttributeSetting

 public void WindowsAttributeSetting(FileAttributes attr)
 {
     var path = GetTestFilePath();
     File.Create(path).Dispose();
     Set(path, attr);
     Assert.Equal(attr, Get(path));
     Set(path, 0);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:GetSetAttributes.cs


示例17: WindowsAttributeSetting

 public void WindowsAttributeSetting(FileAttributes attr)
 {
     var test = new DirectoryInfo(GetTestFilePath());
     test.Create();
     Set(test.FullName, attr);
     Assert.Equal(attr | FileAttributes.Directory, Get(test.FullName));
     Set(test.FullName, 0);
 }
开发者ID:shmao,项目名称:corefx,代码行数:8,代码来源:GetSetAttributes.cs


示例18: ClearAttributes

 /// <summary>
 /// Attempts to clear the specified attribute(s) on the given path.
 /// </summary>
 public static void ClearAttributes(this IFileService fileService, string path, FileAttributes attributes)
 {
     FileAttributes currentAttributes = fileService.GetAttributes(path);
     if ((currentAttributes & attributes) != 0)
     {
         fileService.SetAttributes(path, currentAttributes &= ~attributes);
     }
 }
开发者ID:Priya91,项目名称:XTask,代码行数:11,代码来源:FileServiceExtensions.cs


示例19: NewItem

 public void NewItem(string folderName, string name, FileAttributes attrs)
 {
     ThrowIfDisposed();
     using (ComReleaser<IShellItem> folderItem = CreateShellItem(folderName))
     {
         _fileOperation.NewItem(folderItem.Item, attrs, name, string.Empty, _callbackSink);
     }
 }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:8,代码来源:FileOperation.cs


示例20: AddAttribute

 /// <summary>
 ///     Adds a file attribute
 /// </summary>
 /// <param name="pathInfo">Affected target</param>
 /// <param name="attribute">Attribute to add</param>
 /// <returns>true if added. false if already exists in attributes</returns>
 public static Boolean AddAttribute(PathInfo pathInfo, FileAttributes attribute)
 {
     if ((pathInfo.Attributes & attribute) == attribute) { return false; }
     var attributes = pathInfo.Attributes;
     attributes |= attribute;
     SetAttributes(pathInfo, attributes);
     return true;
 }
开发者ID:i-e-b,项目名称:tinyQuickIO,代码行数:14,代码来源:NativeIO.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FileCodeModel类代码示例发布时间:2022-05-24
下一篇:
C# FileAction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap