FileAttributes
-
How can i change the fileattributes of a file (or folder). I will change the Read-only, Hidden, archive,... tags but i can't find it somewhere. It was no problem to change the creation, last access and last written time, but that class (FileInfo and DirectoryInfo) doesn't have anything to change the attributes of it. Can you help me? Jonathan Slenders
-
How can i change the fileattributes of a file (or folder). I will change the Read-only, Hidden, archive,... tags but i can't find it somewhere. It was no problem to change the creation, last access and last written time, but that class (FileInfo and DirectoryInfo) doesn't have anything to change the attributes of it. Can you help me? Jonathan Slenders
Hi Jonathan. Try the System.IO.File.SetAttributes()[^] static method.
-
How can i change the fileattributes of a file (or folder). I will change the Read-only, Hidden, archive,... tags but i can't find it somewhere. It was no problem to change the creation, last access and last written time, but that class (FileInfo and DirectoryInfo) doesn't have anything to change the attributes of it. Can you help me? Jonathan Slenders
See
FileInfo.Attributes
(inherited formFileSystemInfo
). You can use bitwise operators to change the flags. For instance, to exclude the read-only, hidden, and archive flags, you could do something like this:FileInfo info = new FileInfo("path");
info.Attributes &= ~(FileAttributes.ReadOnly | FileAttributes.Hidden
| FileAttributes.Archive);Microsoft MVP, Visual C# My Articles