1 1 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);
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:

AttributeCodeMeaning
faHidden $00000002Hidden File
faReadOnly $00000001Write Protected File
faSysFile$00000004System File
faArchive$00000020Archive
faDirectory$00000010Folder
faAnyFile$0000003FAny File
faVolumeID$00000008Drive-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).

ReplyPositiveNegative

About the Author

Avatar AuthorThe author has not added a short description to his profile yet.
Show Profile | Message

 

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.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.