Stream

Seekable FTP file stream in C#

Seekable FTP file stream in C#

Certain types of files are dependent on metadata stored within the file itself to be read before the file can be used for anything. One of these file types is the ZIP archive format.

A ZIP-file stores a data directory at the end of the file specifying metadata for the contained files and therefore the data directory is required to be read before attempting to read or extract any of the contained files.

For solving the challenge, I wrapped an FtpWebRequest instance in an implementation inheriting from Stream, as a SeekableFtpFileStream, and thereby allowing the implementation to close and reopen connections with an offset to skip to file offsets of interest on FTP.