HOWTO: Use NTFS Alternate Data StreamsLast reviewed: November 26, 1997Article ID: Q105763 |
The information in this article applies to:
SUMMARYThe documentation for the NTFS file system states that NTFS supports multiple streams of data; however, the documentation does not address the syntax for the streams themselves. The Windows NT Resource Kit documents the stream syntax as follows:
filename:streamAlternate data streams are strictly a feature of the NTFS file system and may not be supported in future file systems. However, NTFS will be supported in future versions of Windows NT. Future file systems will support a model based on OLE 2.0 structured storage (IStream and IStorage). By using OLE 2.0, an application can support multiple streams on any file system and all supported operating systems (Windows, Macintosh, Windows NT, and Win32s), not just Windows NT.
MORE INFORMATIONThe following sample code demonstrates NTFS streams:
Sample Code
#include <windows.h> #include <stdio.h> void main( ) { HANDLE hFile, hStream; DWORD dwRet; hFile = CreateFile( "testfile", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL ); if( hFile == INVALID_HANDLE_VALUE ) printf( "Cannot open testfile\n" ); else WriteFile( hFile, "This is testfile", 16, &dwRet, NULL ); hStream = CreateFile( "testfile:stream", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL ); if( hStream == INVALID_HANDLE_VALUE ) printf( "Cannot open testfile:stream\n" ); else WriteFile(hStream, "This is testfile:stream", 23, &dwRet, NULL); }The file size obtained in a directory listing is 16, because you are looking only at "testfile", and therefore
type testfileproduces the following:
This is testfileHowever
type testfile:streamproduces the following:
The filename syntax is incorrectIn order to view what is in testfile:stream, use:
more < testfile:stream -or- mep testfile:streamwhere "mep" is the Microsoft Editor available in Win32 SDK. Keywords : BseFileio Version : winnt:3.1,3.5,3.51,4.0; Platform : winnt Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |