Every file stored in a CBFS Storage vault contains a primary stream of data that holds the file's contents. In addition to this primary stream, files in a vault may also contain one or more alternate streams of data whose contents are determined by the application. By taking advantage of the flexibility that alternate streams offer, applications can support a wide range of use-cases; for example:
- Storing a file's metadata and/or security information.
- Saving supplementary information associated with a file (e.g., song lyrics for music files).
- Maintaining a history of file content revisions.
- Providing multiple representations of the same file (e.g., HTML, RTF, and plain versions of text content).
Alternate streams are addressed using names like <FileName>:<StreamName>, so an alternate stream named "altstream" could be addressed as \path\to\filename.ext:altstream. Alternate streams can be created and accessed just like files using OpenFile, OpenFileEx, DeleteFile, etc.; and can even be compressed and/or encrypted individually if an application desires.
To enumerate a file's alternate streams, call the FindFirst method with a mask like <FileName>:<StreamNameMask>. The <StreamNameMask> part can be * to enumerate all streams in a file. A file's main stream, which is always nameless, can be accessed explicitly using the name <FileName>: (note the trailing colon).