-3

如何更改现有文件夹的属性?

我必须使这个文件夹和其中存在的所有文件可见。

C:\Documents and Settings\%USER%\appdata

我找到了这段代码:

FileAttributes attributes = File.GetAttributes(@"C:\Documents and Settings\%user%\Dane aplikacji");

attributes = RemoveAttribute(attributes, FileAttributes.Hidden);


private static FileAttributes RemoveAttribute(FileAttributes attributes, FileAttributes attributesToRemove)
    {
        return attributes & ~attributesToRemove;
    }

但它不工作:(

谢谢 !

4

1 回答 1

2

在您的代码中,您只是在更新属性变量,但实际上并未更新文件的属性。

你需要使用File.SetAttributes('path', attributes)

于 2014-10-10T13:19:53.660 回答