本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.FlushAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.FlushAsync方法的具体用法?C# IsolatedStorageFileStream.FlushAsync怎么用?C# IsolatedStorageFileStream.FlushAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.FlushAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadAsync
public async Task DownloadAsync(string url, IDictionary<string, string> headers, string method, string saveAs)
{
// Download the data
var data = await this.DownloadAsync(url, headers, method);
// Get the local folder.
var localStorage = IsolatedStorageFile.GetUserStoreForApplication();
// Write the file
using (var memStream = new MemoryStream(data))
{
using (var stream = new IsolatedStorageFileStream(saveAs, FileMode.CreateNew, FileAccess.Write, FileShare.None, localStorage))
{
await memStream.CopyToAsync(stream);
await stream.FlushAsync();
}
}
}
示例2: 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);
}