Delphi: Change File Attributes of Files
Info by Progger99 | Last update on 2021-05-12 | Created on 2012-06-19
Sometimes you have to change the file attributes of files via Delphi, for example, to hide a file or to give the file a write-portection. That is how to do it:
procedure TForm1.Button1Click(Sender: TObject); begin FileSetAttr('C:\File.txt', faHidden); end;
This sets the file to "faHidden", meaning the file will be hidden. Apart from that, the following attributes of the file can be set:
Attribute | Code | Meaning |
faHidden | $00000002 | Hidden File |
faReadOnly | $00000001 | Write Protected File |
faSysFile | $00000004 | System File |
faArchive | $00000020 | Archive |
faDirectory | $00000010 | Folder |
faAnyFile | $0000003F | Any File |
faVolumeID | $00000008 | Drive-ID |
It is also possible to set several attributes at once. This can be accomplished with:
FileSetAttr('C:\File.txt', faHidden + faReadOnly);
This sets the file "File.txt" to hidden and read-only (write protected).
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
MySQL: Line Breaks in MySQL
Tip | 0 Comments
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
jQuery: Show and hide elements
Tutorial | 0 Comments
jQuery: Read and Change Data Attribute Value
Tutorial | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
HTML: Difference between ID and CLASS
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.