Given a file, and we have to get and print file’s attribute using C# program.
File.GetAttributes()
This is a method of "File" class, which returns the specified file's attributes.
Syntax:
FileAttributes GetAttributes(path);
Parameter(s):
- path - Filename with its location.
Return value:
This method returns object of FileAttributes, File attribute 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