Windows phone 8 在windows phone 8中使用SharpCompress或Sytem.IO.Compression或

Windows phone 8 在windows phone 8中使用SharpCompress或Sytem.IO.Compression或,windows-phone-8,zip,c#-5.0,sharpcompress,Windows Phone 8,Zip,C# 5.0,Sharpcompress,我正在使用Windows phone 8应用商店应用程序,需要压缩本地存储文件夹(带有一些图像)。环境VS 2013。 我了解到我只能添加对SharpCompress&System.IO.Compression(而不是.FileSystem)的引用 SharpZipLib和DotNetZip似乎不支持WP8 SharpCompress给出的示例不起作用 任何带有代码的建议都会很有帮助。谢谢。System.IO.Compression: string GuidPath = Path.Combine

我正在使用Windows phone 8应用商店应用程序,需要压缩本地存储文件夹(带有一些图像)。环境VS 2013。 我了解到我只能添加对SharpCompress&System.IO.Compression(而不是.FileSystem)的引用

SharpZipLib和DotNetZip似乎不支持WP8

SharpCompress给出的示例不起作用

任何带有代码的建议都会很有帮助。谢谢。

System.IO.Compression:

string GuidPath = Path.Combine(LocalStorage, Guid.NewGuid().ToString()) + ".zip";
                        using (FileStream zipToOpen = new FileStream(GuidPath, FileMode.Create))
                        {
                            using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create))
                            {
                                String[] files = Directory.GetFiles(szFldrPath);
                                foreach( String echFile in files )
                                {
                                    ZipArchiveEntry readmeEntry = archive.CreateEntry(Path.GetFileName(echFile));
                                    using (BinaryWriter writer = new BinaryWriter(readmeEntry.Open()))
                                    {
                                        using (Stream source = File.OpenRead(echFile))
                                        {
                                            byte[] buffer = new byte[4096];
                                            int bytesRead;
                                            while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
                                            {
                                                writer.Write(buffer, 0, bytesRead);
                                            }
                                        }
                                    }
                                }
                            }
                        }
如何使用: