![]() ![]() String zipPath = path where to extract the zip file:") ĮxtractPath = Path.GetFullPath(extractPath) The following example shows how to open a zip archive and iterate through the collection of entries. Writer.WriteLine("Information about this package.") Using writer As StreamWriter = New StreamWriter(readmeEntry.Open()) Using archive As ZipArchive = New ZipArchive(zipToOpen, ZipArchiveMode.Update)ĭim readmeEntry As ZipArchiveEntry = archive.CreateEntry("Readme.txt") Using zipToOpen As FileStream = New FileStream("c:\users\exampleuser\release.zip", FileMode.Open) ![]() Using (StreamWriter writer = new StreamWriter(readmeEntry.Open())) ZipArchiveEntry readmeEntry = archive.CreateEntry("Readme.txt") Using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update)) Using (FileStream zipToOpen = new FileMode.Open)) The first example shows how to create a new entry and write to it by using a stream. In Windows 8.x Store apps, you can compress and decompress files by using the DeflateStream or GZipStream class, or you can use the Windows Runtime types Compressor and Decompressor. The System.IO.Compression.FileSystem assembly is not available for Windows 8.x Store apps. These extension methods enable you to compress and decompress the contents of the entry to a file. If you reference the System.IO.Compression.FileSystem assembly in your project, you can access four extension methods (from the ZipFileExtensions class) for the ZipArchive class: CreateEntryFromFile(ZipArchive, String, String), CreateEntryFromFile(ZipArchive, String, String, CompressionLevel), ExtractToDirectory(ZipArchive, String), and ExtractToDirectory(ZipArchive, String, Boolean) (available in. For example, creating a new entry with a relative path of AddedFolder\NewFile.txt creates a compressed text file in a directory named AddedFolder. You include the relative path of the new entry within the zip package. The CreateEntry method enables you to specify a directory hierarchy when adding the entry. When you create a new entry, the file is compressed and added to the zip package. Open a stream to a single file contained in a zip archive ![]() Retrieve all the files from a zip archive ToĮxtract the contents of a zip archive to a directory The methods for manipulating zip archives and their file entries are spread across three classes: ZipFile, ZipArchive, and ZipArchiveEntry. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |