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


C# IsolatedStorageFileStream.CopyToAsync方法代码示例

本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.CopyToAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.CopyToAsync方法的具体用法?C# IsolatedStorageFileStream.CopyToAsync怎么用?C# IsolatedStorageFileStream.CopyToAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IsolatedStorage.IsolatedStorageFileStream的用法示例。


在下文中一共展示了IsolatedStorageFileStream.CopyToAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadAsync

        public async Task UploadAsync(string url, IDictionary<string, string> headers, string method, string file)
        {
            byte[] data = null;

            // Get the local folder.
            var localStorage = IsolatedStorageFile.GetUserStoreForApplication();

            using (var fileStream = new IsolatedStorageFileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, localStorage))
            {
                using (var memStream = new MemoryStream())
                {
                    await fileStream.CopyToAsync(memStream);
                    await fileStream.FlushAsync();
                    await memStream.FlushAsync();
                    data = memStream.ToArray();
                }
            }
            await UploadAsync(url, headers, method, data);
        }
开发者ID:neilunadkat,项目名称:appacitive-dotnet-sdk,代码行数:19,代码来源:WebClientHttpFileHandler.cs

示例2: RestoreState

        /// <summary>
        /// Restores the page state if application was tombstoned.
        /// </summary>
        private async void RestoreState()
        {
            // Load the image which was filtered from isolated app storage.
            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                if (myStore.FileExists(TombstoneImageFile))
                {
                    using (var isoFileStream = new IsolatedStorageFileStream(
                        TombstoneImageFile, 
                        FileMode.Open, 
                        myStore))
                    {
                        DataContext dataContext = FilterEffects.DataContext.Instance;

                        // Load image asynchronously at application launch
                        await isoFileStream.CopyToAsync(dataContext.FullResolutionStream);
                        Dispatcher.BeginInvoke(() =>
                        {
                            CreatePreviewImages();
                        });
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error while trying to restore temporary image.");
            }

            // Remove temporary file from isolated storage
            try
            {
                if (myStore.FileExists(TombstoneImageFile))
                {
                    myStore.DeleteFile(TombstoneImageFile);
                }
            }
            catch (IsolatedStorageException /*ex*/)
            {
                MessageBox.Show("Error while trying to delete temporary image.");
            }

            // Load also the preview index which was last used
            if (State.ContainsKey("PivotIndex"))
            {
                FilterPreviewPivot.SelectedIndex = (int)State[StateIndexKey];
            }
        }
开发者ID:sachin4203,项目名称:ClassicPhotoEditor,代码行数:52,代码来源:PreviewPage.xaml.cs


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