本文整理汇总了C#中IFolder.GetFilesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IFolder.GetFilesAsync方法的具体用法?C# IFolder.GetFilesAsync怎么用?C# IFolder.GetFilesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFolder
的用法示例。
在下文中一共展示了IFolder.GetFilesAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileCache
internal FileCache(string cacheToken)
{
_cacheToken = cacheToken;
_folder = FileSystem.Current.LocalStorage.CreateFolderAsync(_cacheToken, CreationCollisionOption.OpenIfExists).Result;
_httpClient = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = true, CookieContainer = Client.CookieContainer, UseCookies = true });
_cachedFiles = new Dictionary<string, string>();
IList<IFile> files = _folder.GetFilesAsync().Result;
foreach(IFile file in files)
{
_cachedFiles.Add(file.Name, file.Path);
}
}
示例2: DirSize
public static async Task<long> DirSize(IFolder d, Func<string, long> GetFolderSize, Func<string, long> GetFileSize)
{
long Size = 0;
// Add file sizes.
IList<IFile> fis = await d.GetFilesAsync();
foreach (IFile fi in fis)
{
Size += GetFileSize(fi.Path);
}
// Add subdirectory sizes.
IList<IFolder> fols = await d.GetFoldersAsync();
foreach (IFolder fo in fols)
{
Size += GetFolderSize(fo.Path);
}
return (Size);
}
示例3: RollingLogFileNameAsync
private async Task<string> RollingLogFileNameAsync(IFolder folder)
{
var files = await folder.GetFilesAsync().ConfigureAwait(false);
var counter = 0;
if (files.Count > 0)
{
var logFiles = (from f in files where Regex.Match(f.Name, LOG_FILE_PATTERN).Success select f).OrderBy(f => f.Name).ToList();
if (logFiles.Count > 0)
{
//if the number of files are greater than the max number of files allowed then,
//delete the oldest file. oldest file is the file with the lowest number
while (logFiles.Count > MAX_FILES_COUNT)
{
await logFiles[0].DeleteAsync().ConfigureAwait(false);
logFiles.RemoveAt(0);
}
// the current file is the file at the zeroth index.
var currentFile = logFiles[logFiles.Count - 1];
long fileSize = 0;
using (var stream = await currentFile.OpenAsync(PCLStorage.FileAccess.Read).ConfigureAwait(false))
{
fileSize = stream.Length;
}
if (fileSize < MAX_SIZE)
{
return currentFile.Name;
}
else
{
var fileName = currentFile.Name;
var regex = new Regex(LOG_FILE_PATTERN);
var match = regex.Match(fileName);
if (match.Success)
{
if (int.TryParse(match.Groups["counter"].Value, out counter))
counter++;
}
}
}
}
return string.Format(LOG_FILE_FORMAT, counter);
}
示例4: GetEvents
private async Task<IEnumerable<Event>> GetEvents(IFolder collectionFolder)
{
var files = await collectionFolder.GetFilesAsync();
var fileContents = await TaskEx.WhenAll(files.Select(file => file.ReadAllTextAsync()));
return fileContents.Select(fc => new Event(fc));
}
示例5: IndexFilesAsync
private async Task<IEnumerable<TopicData>> IndexFilesAsync(IFolder folder)
{
var files = await folder.GetFilesAsync(cancellationToken);
return files.Where(IsTopic)
.Select(CreateTopicData);
}