本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}