Set File Attributes in C#
The System.IO namespace contains types that allow reading and writing to files and data streams, and types that provide basic file and directory support.
Use the FileInfo class for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. FileSystemInfo.Attributes property is used to gets or sets the attributes for the current file or directory.
The following C# program shows how to set readonly and hidden property to a file .