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


C# IFileSystem.GetFileAttributes方法代码示例

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


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

示例1: Delete

 public static IFileInfo Delete(IFileSystem fileSystem, string path) {
     var fi = Substitute.For<IFileInfo>();
     fi.FullName.Returns(path);
     fi.Exists.Returns(false);
     fi.Directory.Returns((IDirectoryInfo)null);
     fileSystem.FileExists(path).Returns(false);
     try {
         fileSystem.GetFileAttributes(path).Throws<FileNotFoundException>();
     } catch (IOException) { }
     return fi;
 }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:11,代码来源:FileInfoStubFactory.cs

示例2: Create

        public static IFileInfo Create(IFileSystem fileSystem, string path) {
            var fi = Substitute.For<IFileInfo>();
            fi.FullName.Returns(path);
            fi.Exists.Returns(true);
            fi.Directory.Returns((IDirectoryInfo)null);
            fileSystem.FileExists(path).Returns(true);

            try {
                fileSystem.GetFileAttributes(path);
            } catch (IOException) {
                default(FileAttributes).Returns(FileAttributes.Normal);
            }

            return fi;
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:15,代码来源:FileInfoStubFactory.cs

示例3: NoDelayNoFiltering

            public NoDelayNoFiltering()
            {
                _fileSystem = Substitute.For<IFileSystem>();
                _fileSystem.GetFileAttributes(Arg.Any<string>()).Throws<FileNotFoundException>();
                var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem);

                var fileSystemFilter = Substitute.For<IMsBuildFileSystemFilter>();
                fileSystemFilter.IsFileAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true);
                fileSystemFilter.IsDirectoryAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true);

                _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current);

                _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 0, _fileSystem, fileSystemFilter, _taskScheduler, NullLog.Instance);
                _fileSystemWatcher.Start();

                _fileWatcher = watchers.FileWatcher;
                _directoryWatcher = watchers.DirectoryWatcher;
                _attributesWatcher = watchers.AttributesWatcher;
            }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:19,代码来源:MsBuildFileSystemWatcherTest.NoDelayNoFiltering.cs

示例4: NoDelayNoFiltering

            public NoDelayNoFiltering() {
                _fileSystem = Substitute.For<IFileSystem>();
                _fileSystem.GetFileAttributes(Arg.Any<string>()).Throws<FileNotFoundException>();
                _fileSystem.ToLongPath(Arg.Any<string>()).Returns(ci => ci[0]);
                _fileSystem.ToShortPath(Arg.Any<string>()).Returns(ci => ci[0]);
                var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem);

                var fileSystemFilter = Substitute.For<IMsBuildFileSystemFilter>();
                fileSystemFilter.IsFileAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true);
                fileSystemFilter.IsDirectoryAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true);

                _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current);

                DirectoryInfoStubFactory.Create(_fileSystem, ProjectDirectory);
                _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 0, 0, _fileSystem, fileSystemFilter, Substitute.For<IActionLog>(), _taskScheduler);
                _fileSystemWatcher.Start();

                _fileWatcher = watchers.FileWatcher;
                _directoryWatcher = watchers.DirectoryWatcher;
                _attributesWatcher = watchers.AttributesWatcher;
            }
开发者ID:Microsoft,项目名称:RTVS,代码行数:21,代码来源:MsBuildFileSystemWatcherTest.NoDelayNoFiltering.cs

示例5: IsFileAllowed

        private static bool IsFileAllowed(string rootDirectory, string fullPath, IFileSystem fileSystem, IMsBuildFileSystemFilter filter, out string relativePath) {
            if (!fullPath.StartsWithIgnoreCase(rootDirectory)) {
                relativePath = null;
                return false;
            }

            relativePath = PathHelper.MakeRelative(rootDirectory, fullPath);
            try {
                return filter.IsFileAllowed(relativePath, fileSystem.GetFileAttributes(fullPath));
            } catch (IOException) {
                // File isn't allowed if it isn't accessable
                return false;
            }
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:14,代码来源:MsBuildFileSystemWatcher.cs

示例6: IsFileAllowed

 private static bool IsFileAllowed(string rootDirectory, string fullPath,
     IFileSystem fileSystem, IMsBuildFileSystemFilter filter,
     out string relativePath, out string shortRelativePath) {
     relativePath = null;
     shortRelativePath = null;
     if (fullPath.StartsWithIgnoreCase(rootDirectory)) {
         relativePath = PathHelper.MakeRelative(rootDirectory, fullPath);
          try {
             shortRelativePath = fileSystem.ToShortRelativePath(fullPath, rootDirectory);
             return !string.IsNullOrEmpty(shortRelativePath) && filter.IsFileAllowed(relativePath, fileSystem.GetFileAttributes(fullPath));
         } catch (IOException) { } catch (UnauthorizedAccessException) { } // File isn't allowed if it isn't accessible
     }
     return false;
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:14,代码来源:MsBuildFileSystemWatcher.cs


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