11 Vote

Delphi: Change File Attributes of Files

Info by Progger99 | 19.06.2012 at 23:30

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);
   FileSetAttr('C:\File.txt', faHidden);

This sets the file to "faHidden", meaning the file will be hidden. Apart from that, the following attributes of the file can be set:

faHidden $00000002Hidden File
faReadOnly $00000001Write Protected File
faSysFile$00000004System File
faAnyFile$0000003FAny File

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

AvatarThe author has not added a profile short description yet.
Show Profile


Related Topics

Delphi: Hide Files
Question | 2 Answers
Change Date of File
Tutorial | 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.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.