コード例 #1
0
        public async Task <string> PickImageAsync(string source)
        {
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            StorageFile result = await picker.PickSingleFileAsync();

            if (result != null && !string.IsNullOrEmpty(result.Path))
            {
                if (!string.IsNullOrEmpty(source))
                {
                    WinIsolatedStorage.DeleteAsync(source);
                }

                string      filename = "background-" + Guid.NewGuid() + Path.GetExtension(result.Path);
                StorageFile file     = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

                await result.CopyAndReplaceAsync(file);

                return(filename);
            }

            return(null);
        }
コード例 #2
0
 public async Task SaveFileAsync <T>(T item, string filename)
 {
     await WinIsolatedStorage.SaveAsync(item, filename);
 }
コード例 #3
0
 public async Task <T> LoadFileAsync <T>(string filename)
 {
     return(await WinIsolatedStorage.RestoreAsync <T>(filename));
 }
コード例 #4
0
 public async Task DeleteFileAsync(string path)
 {
     await WinIsolatedStorage.DeleteAsync(path);
 }