1

如何以编程方式读取和写入由 Windows“允许此驱动器上的文件除了文件属性之外还有内容索引”对话框设置的文件和文件夹属性?

4

1 回答 1

2

显然是这样的:

// read
var isContentIndexed = ((attributes & FileAttributes.NotContentIndexed) != FileAttributes.NotContentIndexed);

// set
File.SetAttributes(path, (File.GetAttributes(path) | FileAttributes.NotContentIndexed));

// remove
File.SetAttributes(path, (File.GetAttributes(path) & ~FileAttributes.NotContentIndexed));
于 2015-01-17T20:17:46.240 回答