當前位置: 首頁>>代碼示例>>C#>>正文


C# StorageFile.CopyAsync方法代碼示例

本文整理匯總了C#中Windows.Storage.StorageFile.CopyAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# StorageFile.CopyAsync方法的具體用法?C# StorageFile.CopyAsync怎麽用?C# StorageFile.CopyAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Storage.StorageFile的用法示例。


在下文中一共展示了StorageFile.CopyAsync方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreatePageFiles

        public async static Task CreatePageFiles(StorageFile fileToCopy, Guid pageId)
        {
            var localFolder = ApplicationData.Current.LocalFolder;

            await fileToCopy.CopyAsync(localFolder, pageId.ToString() + ".jpg");

            await fileToCopy.CopyAsync(localFolder, pageId.ToString() + "_backup" + ".jpg");
        }
開發者ID:Snail34,項目名稱:MobileScanner,代碼行數:8,代碼來源:LocalStorageHelper.cs

示例2: ParseData

        public async void ParseData(StorageFile file)
        {
            try
            {
                if (!await FileUtil.DirExistsAsync(ConstantsAPI.SDK_TEMP_DIR_PATH))
                {
                    await FileUtil.CreateDirAsync(ConstantsAPI.SDK_TEMP_DIR_PATH);
                }

                var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync(ConstantsAPI.SDK_TEMP_DIR_PATH);
                var copyFile = await file.CopyAsync(folder, "wp.wechat", NameCollisionOption.ReplaceExisting);

                if (await FileUtil.FileExistsAsync(ConstantsAPI.SDK_TEMP_FILE_PATH))
                {
                    TransactData data = await TransactData.ReadFromFileAsync(ConstantsAPI.SDK_TEMP_FILE_PATH);
                    if (!data.ValidateData())
                    {
                        //MessageBox.Show("數據驗證失敗");
                    }
                    else if (!data.CheckSupported())
                    {
                        //MessageBox.Show("當前版本不支持該請求");
                    }
                    else if (data.Req != null)
                    {
                        if (data.Req.Type() == ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX)
                        {
                            OnGetMessageFromWXRequest(data.Req as GetMessageFromWX.Req);
                        }
                        else if (data.Req.Type() == 4)
                        {
                            OnShowMessageFromWXRequest(data.Req as ShowMessageFromWX.Req);
                        }
                    }
                    else if (data.Resp != null)
                    {
                        if (data.Resp.Type() == 1)
                        {
                            OnSendAuthResponse(data.Resp as SendAuth.Resp);
                        }
                        else if (data.Resp.Type() == 2)
                        {
                            OnSendMessageToWXResponse(data.Resp as SendMessageToWX.Resp);
                        }
                        else if (data.Resp.Type() == 5)
                        {
                            OnSendPayResponse(data.Resp as SendPay.Resp);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                //MessageBox.Show(exception.Message);
            }
        }
開發者ID:zhxilin,項目名稱:WeChatSDK,代碼行數:57,代碼來源:WXEntryBasePage.cs

示例3: SaveImageAsync

        private async void SaveImageAsync(StorageFile file)
        {

            if (file != null)
            {
                StorageFile newImageFile = await file.CopyAsync(ApplicationData.Current.LocalFolder, Guid.NewGuid().ToString());

                App.MainViewModel.SelectedBBQRecipe.ImagePath = newImageFile.Path;
            }
        }
開發者ID:TomWalkerCodes,項目名稱:HowToBBQ.Win10,代碼行數:10,代碼來源:BBQRecipeViewModel.cs

示例4: CreateFromStorageFileAsync

 public static async Task<Note> CreateFromStorageFileAsync(StorageFile sf, NoteKind k, string name, string desc, string classId) {
     var docProps = await sf.Properties.GetDocumentPropertiesAsync();
     var imgProps = await sf.Properties.GetImagePropertiesAsync();
     imgProps.DateTaken = DateTime.Now;
     docProps.Title = name;
     docProps.Comment = desc;
     await docProps.SavePropertiesAsync();
     await imgProps.SavePropertiesAsync();
     var fileName = string.Format("{0}_{1}_{2}.{3}", classId, imgProps.DateTaken.ToString("MM-dd-yyyy ss-fff"), k.ToString().ToLower(), k == NoteKind.Txt ? "txt" : k == NoteKind.Img ? "jpg" : "mp4");
     var newFile = await sf.CopyAsync(await ApplicationData.Current.RoamingFolder.CreateFolderAsync("Notes", CreationCollisionOption.OpenIfExists), fileName, NameCollisionOption.ReplaceExisting);
     return await CreateFromStorageFileAsync(newFile);
 }
開發者ID:devgregw,項目名稱:Digital_Classmate,代碼行數:12,代碼來源:Note.cs

示例5: UnzipKmz

 // http://stackoverflow.com/questions/36728529/extracting-specific-file-from-archive-in-uwp
 private async Task UnzipKmz(StorageFile kmzFile)
 {
     StorageFolder folder = ApplicationData.Current.TemporaryFolder;
     // Clear in temporary folder
     ClearTempFolder();
     // Need to copy file to temporary folder
     StorageFile temp = await kmzFile.CopyAsync(folder);
     using (ZipArchive archive = ZipFile.OpenRead(temp.Path))
     {
         foreach (ZipArchiveEntry entry in archive.Entries)
         {
             if (entry.FullName.ToString() == "doc.kml")
             {
                 entry.ExtractToFile(Path.Combine(folder.Path, entry.FullName));
                 // Set KML file
                 kmlFile = await folder.GetFileAsync("doc.kml");
             }
         }
     }
 }
開發者ID:ayamadori,項目名稱:OpenWithMaps,代碼行數:21,代碼來源:KmlConverter.cs

示例6: SaveFiletoLocalAsync

 public static async Task<Uri> SaveFiletoLocalAsync(string path, StorageFile file, string desiredName)
 {
     var local = ApplicationData.Current.LocalFolder;
     try
     {
         var folder = await local.CreateFolderAsync(path, CreationCollisionOption.OpenIfExists);
         await file.CopyAsync(folder, desiredName + file.FileType, NameCollisionOption.ReplaceExisting);
         return new Uri("ms-appdata:///local/" + path.Replace("\\", "/") + '/' + desiredName + file.FileType);
     }
     catch (Exception)
     {
         return null;
     }
 }
開發者ID:aurora-lzzp,項目名稱:Aurora-Weather,代碼行數:14,代碼來源:FileIOHelper.cs

示例7: ChooseBackgroundImage

        private async void ChooseBackgroundImage(StorageFile file)
        {
            String filename = "menuBackground.png";
            
            await file.CopyAsync(ApplicationData.Current.LocalFolder as IStorageFolder, filename, NameCollisionOption.ReplaceExisting);

            AppSettings.BackgroundImage = filename;

            LoadBackgroundImage();
        }
開發者ID:deadkitty,項目名稱:Mobile-Computing,代碼行數:10,代碼來源:MainPage.xaml.cs

示例8: FileOpenPicker_Continuation

 private async void FileOpenPicker_Continuation(StorageFile file)
 {
     if (file != null)
     {
         var destFile = await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.ReplaceExisting);
         var userPhoto = new UserPhotoDataItem() { Title = destFile.Name};
         userPhoto.SetImage(destFile.Path);
         item.UserPhotos.Add(userPhoto);
     }
 }
開發者ID:karolzak,項目名稱:MVA-Channel9,代碼行數:10,代碼來源:RecipeDetailPage.xaml.cs

示例9: SaveUserAvatarFile

 /// <summary>
 ///     Copies the user's avatar's file to it's place (avatars subfolder).
 /// </summary>
 /// <param name="file">The user's avatar's file.</param>
 /// <returns>The copy of the file.</returns>
 private async Task<StorageFile> SaveUserAvatarFile(StorageFile file)
 {
     var copy = await file.CopyAsync(_avatarsFolder);
     await copy.RenameAsync(ToxModel.Instance.Id.PublicKey + ".png", NameCollisionOption.ReplaceExisting);
     return copy;
 }
開發者ID:ProMcTagonist,項目名稱:OneTox,代碼行數:11,代碼來源:AvatarManager.cs

示例10: ExecuteSavePictureCommand

        private async void ExecuteSavePictureCommand(StorageFile file)
        {
            try
            {
                if (file != null)
                {
                    // Copy the file into local folder
                    await file.CopyAsync(ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.GenerateUniqueName);
                    // Save in the ToDoItem
                    TodoItem.ImageUri = new Uri("ms-appdata:///local/" + file.Name);
                }

            }
            finally { Busy = false; }
        }
開發者ID:Ronacs,項目名稱:WinDevCamp,代碼行數:15,代碼來源:TodoItemViewModel.cs

示例11: imgfolder

        private async Task<string> imgfolder(file_storage temp, StorageFile file) //StorageFile file)
        {
            //string str = _file.Name;
            //StorageFolder image = null;
            //try
            //{
            //    image = await _folder.GetFolderAsync(str);
            //}
            //catch
            //{
            //}
            //if (image == null)
            //{
            //    image = await _folder.CreateFolderAsync(str, CreationCollisionOption.OpenIfExists);
            //}
            string str;
            file = await file.CopyAsync(temp.folder, file.Name, NameCollisionOption.GenerateUniqueName);

            if ((file.FileType == ".png") || (file.FileType == ".jpg") || (file.FileType == ".gif"))
            {
                str = $"![這裏寫圖片描述]({temp.folder}/{file.Name})\n\n";
                return str;
            }
            str = $"[{file.Name}]({temp.folder}/{file.Name})\n\n";
            return str;
        }
開發者ID:lindexi,項目名稱:Markdown,代碼行數:26,代碼來源:winmain.cs

示例12: SetImageSource

 public async Task SetImageSource(StorageFile sourceFile)
 {
     var tempFolder = ApplicationData.Current.TemporaryFolder;
     m_ext = sourceFile.Name.Substring(sourceFile.Name.LastIndexOf('.'));
     // original full size image
     //var img = await sourceFile.CopyAsync(tempFolder, m_filename + "a" + m_ext, NameCollisionOption.ReplaceExisting);
     // cropped image will be stored here
     //img = await sourceFile.CopyAsync(tempFolder, m_filename + m_ext, NameCollisionOption.ReplaceExisting);
     //ImageSource = img.Path;
     var f = tempFolder.Path + "\\";
     var i1 = m_filename + "a" + m_ext;
     var i2 = m_filename + m_ext;
     
     // copy new source to temp folder
     await sourceFile.CopyAsync(tempFolder, i1, NameCollisionOption.ReplaceExisting);
     // crop image to target size
     await Common.CropHelper.CropImageAsync(f + i1, f + i2, 1, new Rect(0, 0, ImageWidth, ImageHeight), Common.CropType.GetLargestRect);
     ImageSource = CreateSource(f + i2);
 }
開發者ID:999eagle,項目名稱:StartMenuTiles,代碼行數:19,代碼來源:CreateTilePageViewModel.cs

示例13: CopyFileToFolderOnStorageAsync

        /// <summary>
        /// Copies a file to the first folder on a storage.
        /// </summary>
        /// <param name="sourceFile"></param>
        /// <param name="storage"></param>
        async private Task CopyFileToFolderOnStorageAsync(StorageFile sourceFile, StorageFolder storage)
        {
            var storageName = storage.Name;

            // Construct a folder search to find sub-folders under the current storage.
            // The default (shallow) query should be sufficient in finding the first level of sub-folders.
            // If the first level of sub-folders are not writable, a deep query + recursive copy may be needed.
            var folders = await storage.GetFoldersAsync();
            if (folders.Count > 0)
            {
                var destinationFolder = folders[0];
                var destinationFolderName = destinationFolder.Name;

                rootPage.NotifyUser("Trying the first sub-folder: " + destinationFolderName + "...", NotifyType.StatusMessage);
                try
                {
                    var newFile = await sourceFile.CopyAsync(destinationFolder, sourceFile.Name, NameCollisionOption.GenerateUniqueName);
                    rootPage.NotifyUser("Image " + newFile.Name + " created in folder: " + destinationFolderName + " on " + storageName, NotifyType.StatusMessage);
                }
                catch (Exception e)
                {
                    rootPage.NotifyUser("Failed to copy image to the first sub-folder: " + destinationFolderName + ", " + storageName + " may not allow sending files to its top level folders. Error: " + e.Message, NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("No sub-folders found on " + storageName + " to copy to", NotifyType.StatusMessage);
            }
        }
開發者ID:oldnewthing,項目名稱:old-Windows8-samples,代碼行數:34,代碼來源:S2_SendToStorage.xaml.cs

示例14: SaveBitmapToPictureLibrary

 public async Task SaveBitmapToPictureLibrary(StorageFile image)
 {
     await image.CopyAsync(KnownFolders.PicturesLibrary);
 }
開發者ID:sindrepm,項目名稱:FlickrBrowse,代碼行數:4,代碼來源:PicturesLibraryManager.cs

示例15: SetPictureFile

 public static async void SetPictureFile(StorageFile file)
 {
     // Delete the old picture.
     if (_pictureFile != null)
     {
         await _pictureFile.DeleteAsync();
         await file.CopyAsync(ApplicationData.Current.LocalFolder);
         _pictureFile = file;
     }
     else
     {
         // Check if the file actually does exist.
         try
         {
             StorageFile possibleFile = await ApplicationData.Current.LocalFolder.GetFileAsync(file.Name);
         }
         catch (Exception)
         {
             file.CopyAsync(ApplicationData.Current.LocalFolder);
             _pictureFile = file;
         }
         
     }
     
 }
開發者ID:ASzot,項目名稱:Sudoku-Complete,代碼行數:25,代碼來源:Settings.cs


注:本文中的Windows.Storage.StorageFile.CopyAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。