Given a file, and we have to set its attributes using C# program.
File.SetAttributes()
This is a method of "File class, which is used to define (set) new file attributes.
Syntax:
void SetAttributes (path, FileAttributes);
Parameter(s):
- path - Filename with its location.
- FileAttributes - This object is used to set attributes of file.
File attributes can be following:
- Archive
- Compressed
- Device
- Hidden
- ReadOnly, etc
-
Program
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.
need an explanation for this answer? contact us directly to get an explanation for this answer