本文整理汇总了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);
}
示例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];
}
}