当前位置: 首页>>代码示例>>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;未经允许,请勿转载。