本文整理汇总了C#中IFileSystem.GetFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.GetFile方法的具体用法?C# IFileSystem.GetFile怎么用?C# IFileSystem.GetFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.GetFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExplorerHistoryFiles
public static IEnumerable<ExplorerHistoryFile> GetExplorerHistoryFiles(IFileSystem fileSystem)
{
for (int i = 0; i < paths.Length; i++) {
foreach (FileSystemNode parent in fileSystem.GetFile(paths[i])) {
Folder folder = parent as Folder;
if (folder != null) {
foreach (FileSystemNode node in folder.GetChildren("index.dat")) {
File file = node as File;
if (file != null) {
yield return new ExplorerHistoryFile(file, folder, types[i]);
}
}
}
}
}
}
示例2: CreateFile
private static void CreateFile(AbstractConfigurationDetails configuration, IFileSystem fileSystem)
{
var filePath = System.IO.Path.Combine(configuration.UserDataDirectory, ConfigurationFileName);
using (var file = fileSystem.GetFile(filePath).MustExist().OpenWrite())
file.Write(DefaultFileContents.ToBytes());
}
示例3: CopyDirectoryAsync
static async Task<IFile> CopyDirectoryAsync (this IFileSystem src, IFile file, IFileSystem dest, string destDir)
{
var newPath = await dest.GetAvailableNameAsync (Path.Combine (destDir, Path.GetFileName (file.Path)));
var r = await dest.CreateDirectory (newPath);
if (!r)
throw new Exception ("Failed to create destination directory " + newPath + " on " + dest);
var srcFiles = await src.ListFiles (file.Path);
foreach (var f in srcFiles) {
await src.CopyAsync (f, dest, newPath);
}
try {
return await dest.GetFile (newPath);
} catch (Exception ex) {
Log.Error (ex);
return null;
}
}
示例4: TryParse
public static SolutionProjectReference TryParse(IFileSystem fileSystem, string[] lines, ref int index)
{
var match = _projectRegex.Match(lines[index]);
if (match.Success == false) return null;
var project = new SolutionProjectReference
{
Name = match.Groups["name"].Value,
Path = match.Groups["path"].Value,
Type = new Guid(match.Groups["projectTypeGuid"].Value),
Guid = new Guid(match.Groups["projectGuid"].Value),
File = fileSystem.GetFile(match.Groups["path"].Value)
};
for (index++; index < lines.Length; index++)
{
if (lines[index] == "EndProject") break;
project._lines.Add(lines[index]);
}
return project;
}
示例5: Exists
public static bool Exists(this FilePath path, IFileSystem fileSystem)
{
var file = fileSystem.GetFile(path);
return file != null && file.Exists;
}