本文整理汇总了C#中Windows.Storage.StorageFile.GetParentAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StorageFile.GetParentAsync方法的具体用法?C# StorageFile.GetParentAsync怎么用?C# StorageFile.GetParentAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.Storage.StorageFile
的用法示例。
在下文中一共展示了StorageFile.GetParentAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPath
private async Task<string> GetPath(StorageFile file)
{
string path = "";
if (file != null)
{
if (!string.IsNullOrEmpty(file.Path))
return file.Path;
path = file.Name;
var folder = await file.GetParentAsync();
while (folder != null)
{
path = folder.Name + "\\" + path;
folder = await folder.GetParentAsync();
}
}
return path;
}
示例2: AddImageToWhitelistAsync
public async Task<bool> AddImageToWhitelistAsync(StorageFile imageFile, string personName = null)
{
bool isSuccess = true;
// imageFile should be valid image file
if (!FaceApiUtils.ValidateImageFile(imageFile))
{
isSuccess = false;
}
else
{
var filePath = imageFile.Path;
// If personName is null/empty, use the folder name as person name
if(string.IsNullOrEmpty(personName))
{
personName = await FaceApiUtils.GetParentFolderNameAsync(imageFile);
}
// If person name doesn't exists, add it
var personId = _whitelist.GetPersonIdByName(personName);
if(personId == Guid.Empty)
{
var folder = await imageFile.GetParentAsync();
personId = await CreatePerson(personName, folder);
}
// detect faces
var faceId = await DetectFaceFromImage(imageFile);
await AddFace(personId, faceId, imageFile.Path);
// train whitelist
isSuccess = await TrainingWhitelistAsync();
}
return isSuccess;
}
示例3: GetParentFolderNameAsync
/// <summary>
/// Accepts a StorageFile and returns the name of the folder the file is stored within
/// </summary>
public static async Task<string> GetParentFolderNameAsync(StorageFile imageFile)
{
var parentFolder = await imageFile.GetParentAsync();
return parentFolder.Name;
}
示例4: FinishDownload
public async Task FinishDownload(StorageFile destinationFile)
{
if (destinationFile != null)
{
StorageFolder parentFolder = await destinationFile.GetParentAsync();
if (destinationFile.FileType.EndsWith(DownloadExtension, StringComparison.OrdinalIgnoreCase))
{
var realDestinationFileName = destinationFile.Name.Substring(0,
destinationFile.Name.IndexOf(DownloadExtension, StringComparison.OrdinalIgnoreCase));
await FileUtils.MoveFile(destinationFile, parentFolder, realDestinationFileName);
destinationFile = await FileUtils.GetFile(parentFolder, realDestinationFileName);
if (destinationFile == null)
{
throw new InvalidOperationException("File move while finalizing file failed.");
}
}
if (destinationFile.FileType.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
{
IsDownloading = true;
IsIndeterminate = true;
InstallationStep = Resources.extracting_message;
try
{
await QuranApp.NativeProvider.ExtractZip(destinationFile, parentFolder);
}
finally
{
await FileUtils.SafeFileDelete(destinationFile);
}
}
}
}