<![CDATA[

Overview

This example is an illustration of using Native .Net features to perform file compression and decompression.  Inputs are simple strings that can represent both directories and files.

User Story

As a developer I want a library that can compress or decompress the input I specify to the output location I specify so that I can utilize it in applications that required manipulation of file sizes.

Acceptance Criteria

  • The class constructor will accept the input location as a string
  • The class constructor will accept the output destination as a string
  • The class constructor will set the value of the input location property based on the input location parameter
  • The class constructor will set the value of the output destination property based on the output destination parameter
  • The class will implement a method for the compression of files
  • The compression method will act on the value of the input location property and produce compressed files in the location the output destination property specifies
  • The decompression method will act on the value of the input location property and extract its contents to the location specified in the output destination property

Implementation

https://gist.github.com/natthompson/56b41cf371cb7e02630737c98421bd3c.js

Conclusion

This simple utility class can be utilized to manage file compression and decompression via the .Net Core libraries.  It is not necessary to license and implement a third party library for file compression as these features are native to .Net.
The Program.cs listing demonstrates how this class can be used within a simple console application.  This basic example can be built upon in more complex scenarios to manufacture solutions that meet a wide variety of needs.

Questions?

What use cases can you see utilizing this functionality?  Do you have suggestions on how it can be improved or simplified?  Please comment below to provide your feedback and spark additional discussion.

Stay Up to Date

If you'd like to be notified whenever new content like this is available on the site make sure to sign up for my mailing list.  It is full of news, how to articles and strategies for software development, technology and DevOps and it is delivered right to your digital doorstep as soon as new content goes up on the site.
 ]]>