【发布时间】:2015-03-14 22:55:09
【问题描述】:
如何以编程方式读取和写入由 Windows“允许此驱动器上的文件除了文件属性之外还有内容索引”对话框设置的文件和文件夹属性?
【问题讨论】:
标签: c# .net windows indexing file-attributes
如何以编程方式读取和写入由 Windows“允许此驱动器上的文件除了文件属性之外还有内容索引”对话框设置的文件和文件夹属性?
【问题讨论】:
标签: c# .net windows indexing file-attributes
显然是这样的:
// 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));
【讨论】: