你好我正在学习windows phone 8,我有保存文件的问题,基本上我从web服务下载zip文件,我需要保存它,但我无法做到这一点。我想保存inStream的内容有什么建议吗?
private async Task saveSetupFile(Stream inStream)
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
var myFolder = await local.CreateFolderAsync("AuditsSetupFiles", CreationCollisionOption.OpenIfExists);
var file = await myFolder.CreateFileAsync("EquipSetup.zip", CreationCollisionOption.ReplaceExisting);
var outStream = await file.OpenStreamForWriteAsync();
byte [] buffer = new byte[1024];
int len;
using (var s = await file.OpenStreamForWriteAsync())
{
}
答案 0 :(得分:1)
这应该有效:
private async Task SaveSetupFile(Stream inStream)
{
var localFolder = ApplicationData.Current.LocalFolder;
var folder = await localFolder.CreateFolderAsync("AuditsSetupFiles", CreationCollisionOption.OpenIfExists);
var file = await folder.CreateFileAsync("EquipSetup.zip", CreationCollisionOption.ReplaceExisting);
using (var outStream = await file.OpenStreamForWriteAsync())
{
await inStream.CopyToAsync(outStream);
}
}