topic | languages | products | |||||
---|---|---|---|---|---|---|---|
sample |
|
|
Shows how to read structured data from a file and write compressed data to a new file and how to read compressed data and write decompressed data to a new file.
Note: This sample is part of a large collection of UWP feature samples. If you are unfamiliar with Git and GitHub, you can download the entire collection as a ZIP file, but be sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, the samples collection, and GitHub, see Get the UWP samples from GitHub. For more samples, see the Samples portal on the Windows Dev Center.
Many apps need to compress and decompress data. The Windows.Storage.Compression namespace simplifies this task by providing a unified interface that exposes the MSZIP, XPRESS, XPRESS_HUFF, and LZMS compression algorithms. This lets you manage versions, service, and extend the exposed compression algorithms and frees you from responsibility for managing block sizes, compression parameters, and other details that the native Compression API requires. A subset of Win32 and COM for apps can be used by apps to support scenarios not already covered by the Windows Runtime, HTML/Cascading Style Sheets (CSS), or other supported languages or standards. For this purpose, you can also use the native Compression API to develop apps.
Specifically, this sample shows the following:
- Read uncompressed data from an existing file
- Specify the compression algorithm to use.
- Compress the data using the selected compression algorithm.
- Write the compressed data to a new file.
- Read the compressed data from a file.
- Decompress the data.
To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to Visual Studio
- Compression sample for JavaScript (archived)
- Windows 10
- If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
- Start Microsoft Visual Studio 2017 and select File > Open > Project/Solution.
- Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file.
- Press Ctrl+Shift+B, or select Build > Build Solution.
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
Deploying the sample
-
To deploy the built sample:
- Select Compression in Solution Explorer.
- Use Build > Deploy Solution or Build > Deploy Compression.
Deploying and running the sample
-
To deploy and run the sample:
- Right-click Compression in Solution Explorer and select Set as StartUp Project.
- To debug the sample and then run it, press F5 or use Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
To deploy and run the Windows Phone version of the sample: