# Compound File Optimization

Asynchronous storage enables applications to precisely lay out their compound files so that data is available in the order in which applications will need it. If an application requires only part of its data to display a first page of information, this data can be placed at the beginning of the file, even if it logically resides at the end of a stream. Data from different streams can be interleaved. Audio and video data, for example, can be interleaved so that subsequent read operations retrieve both simultaneously, a requirement for multimedia applications.

New applications can optimize their compound files programmatically by calling the StgOpenLayoutDocfile API function. This function calls the ILayoutStorage interface, which is implemented by the root storage of the new compound files implementation. ILayoutStorage has member functions for scripting the layout of data, monitoring downloads to determine the order in which data is accessed, and rewriting the compound file to match the layout specified by scripting or determined by monitoring. The call to rewrite a file must occur before releasing the last pointer to the root storage of the file. Otherwise, the file will not be altered.

Legacy applications can optimize their compound files by using the Docfile Layout Tool (dflayout.exe) included in the Win32 SDK. This capability, combined with a blocking storage enable legacy applications to progressively download and render their data.