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


C# StorageFile.GetParentAsync方法代码示例

本文整理汇总了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;
 }
开发者ID:flecoqui,项目名称:Windows10,代码行数:17,代码来源:MainPage.xaml.cs

示例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;
        }
开发者ID:ms-iot,项目名称:Facial-Recognition-Door,代码行数:37,代码来源:FaceApiRecognizer.cs

示例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;
 }
开发者ID:vishalishere,项目名称:Facial-Recognition-Door,代码行数:8,代码来源:FaceApiUtils.cs

示例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);
                    }
                }
            }
        }
开发者ID:hubaishan,项目名称:quran-phone,代码行数:35,代码来源:DownloadableViewModelBase.cs


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