public override IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace) { return(AsyncInfo.Run(async(cancellationToken) => { var hFile = NativeFileOperationsHelper.OpenFileForRead(ContainerPath); if (hFile.IsInvalid) { return; } using (ZipFile zipFile = new ZipFile(new FileStream(hFile, FileAccess.Read))) { zipFile.IsStreamOwner = true; var znt = new ZipNameTransform(ContainerPath); var entry = zipFile.GetEntry(znt.TransformFile(Path)); if (entry != null) { using var hDestFile = fileToReplace.CreateSafeFileHandle(FileAccess.ReadWrite); using (var inStream = zipFile.GetInputStream(entry)) using (var outStream = new FileStream(hDestFile, FileAccess.Write)) { await inStream.CopyToAsync(outStream); await outStream.FlushAsync(); } } } })); }
public void NullStorageFile_ThrowsArgumentNull() { IStorageFile file = null; AssertExtensions.Throws <ArgumentNullException>("windowsRuntimeFile", () => file.CreateSafeFileHandle()); }