Project DescriptionThis is a set of interfaces, tests, and sample implementations for wrapping up file systems and file containers.
How many times have you written some code to test simple file systems? Or folders? Or zip files?
This library is a lightweight set of components for making working with file systems (or things that contain files) easier, testable, and flexible. The components demonstrate a use case for abstraction, polymorphism, interface-based programming, and the Strategy Pattern as each implementation of the contract described here is a strategy.
The API documentation contains the interfaces with documentation for each method. The Sample Usage contains implementations of the IFile and IFileContainer using Files, Folders, and a Zip File (which implements IFileContainer) using
SharpZipLib to do the work of the zipping of files.
The solution consists of three projects:
- FileStrategyLib.Interface contains the IFile and IFileContainer interfaces.
- FileStrategyLib.Test contains the unit tests for the file, folder, and zip file wrappers
- FileStrategyLib contains the implementation of the interfaces for files (IFile), folders (IFileContainer) and zip files (IFileContainer)
The Unit Test project provides tests for creating files and directories as well as excercising the zip implementation. The Unit Tests are self contained and clean up after themselves.
You can download the latest release from
here.
API DocumentationSample Usage What could you do with this? There are lots of things you can consider to treat like a file/file container. For example:
- SharePoint Document Libraries
- Database blobs that contain Documents
- Other types of file compressors (Zip, RAR, CAB, etc.)
- FTP sites
Have fun and please feel free to expand or extend this. The original code was written for a simple project where all that was needed was add and delete. Of course you may need additional functionality like extracting files from a container, etc.
Feel free to submit patches to the library or samples for additional usage.