當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。