备用数据流是 NTFS 鲜为人知的功能之一。从页面引用:
C:\test>echo "ADS" > test.txt:hidden.txt
C:\test>dir
Volume in drive C has no label.
Volume Serial Number is B889-75DB
Directory of C:>test
10/22/2003 11:22 AM
. 10/22/2003 11:22 AM
.. 10/22/2003 11:22 AM 0 test.txt
C:\test> notepad test.txt:hidden.txt
This will open the file in notepad and allow you to edit it and save it.
它类似于 Macintosh 资源分支,即它允许将任意数据与文件相关联,而不是文件本身的一部分。Explorer 默认不理解它,但你可以为它编写一个列处理程序。
编辑
可以使用OLE 文档属性保存一些元数据(例如作者和标题)。我不知道它是否会修改文件本身,但:
private void button1_Click(object sender, EventArgs e)
{
//This is the PDF file we want to update.
string filename = @"c:\temp\MyFile.pdf";
//Create the OleDocumentProperties object.
DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
//Open the file for writing if we can. If not we will get an exception.
dso.Open(filename, false,
DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
//Set the summary properties that you want.
dso.SummaryProperties.Title = "This is the Title";
dso.SummaryProperties.Subject = "This is the Subject";
dso.SummaryProperties.Company = "RTDev";
dso.SummaryProperties.Author = "Ron T.";
//Save the Summary information.
dso.Save();
//Close the file.
dso.Close(false);
}