locked
how to zip files in windows phone 8.1? RRS feed

  • 问题

  • I am using the code following:

    StorageFile file = await folder.GetFileAsync("recording.mp4"); StorageFile file1 = await folder.GetFileAsync("capturing.mp4"); StorageFile zipFile = await folder.CreateFileAsync("Record.gz", CreationCollisionOption.ReplaceExisting); //FileInfo using (var writeStream = await zipFile.OpenAsync(FileAccessMode.ReadWrite)) { //FileRandomAccessStream fileStream = writeStream as FileRandomAccessStream; using (GZipStream Compress = new GZipStream(writeStream.AsStreamForWrite(), CompressionMode.Compress)) { using (IRandomAccessStream readStream = await file.OpenReadAsync()) { Stream stream = readStream.GetInputStreamAt(0).AsStreamForRead(); stream.CopyTo(Compress); await Compress.FlushAsync(); } using (IRandomAccessStream readStream = await file1.OpenReadAsync()) { Stream stream = readStream.GetInputStreamAt(0).AsStreamForRead(); stream.CopyTo(Compress); } } }

    I am using GZipStream to compress 2 mp4 file into a gz/zip file. After running the code, i create the gz file successfully,

    but i cant open it in my phone. So, i put the file in my PC, and i can open it while there is only a file without a extension name.

    There should be 2 mp4 in the gz file.

    but after i add ".mp4" to the file it can be played on the PC, but the second mp4 is lost while the file size equals to the total

    size of 2 mp4 files.

    So, can someone tell me that how to zip files correctly in windows phone or how to solve my problems?

    Thanks!~

    2014年8月1日 7:44

答案