1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

FileSetAttr

unit
Sysutils
category
file management routines

declaration
function FileSetAttr(const sFileName: string; Attr : integer): integer;

description
Sets the attributes of a specified file.

FileSetAttr returns 0 (zero) if the function was successful, non-zero value (error code) otherwise. The value of Attr is formed by combining the appropriate file attribute constants:

  • faReadOnly 1 Read-only files.
  • faHidden 2 Hidden files
  • faSysFile 4 System files
  • faVolumeID 8 Volume ID files
  • faDirectory 16 Directory files
  • faArchive 32 Archive files
  • faSymLink 64 Symbolic link
  • faAnyFile 71 Any file

    example
    var mp3File : string;
        Attrs   : integer;
    
    mp3File := 'c:\My Documents\mp3\my_song.mp3'
    
    Attrs := FileGetAttr(mp3File);
    
    //mark mp3File as hidden (if not hidden already)
    if (Attrs and faHidden) = 0 then
      FileSetAttr(mp3File, Attrs or faHidden);
    

    in real code
    Your first MP3 Delphi player
    See how to build a full-blown mp3 player with Delphi in just a few seconds. Even more: get the ID3 tag information from a mp3 file and change it!
    TFindFile VCL
    Tired of using FindFirst, Next and Close? Come see how to encapsulate all those functions in a single "find-files-recursively" component. It's easy to use, free and with code.

    see also
    FileSetReadOnly, FileGetAttr,


     Free Delphi code snippet inside every Delphi Newsletter!
    Subscribe to the Newsletter
    Name
    Email

     Got some code to share? Got a question? Need some help?
  • Explore Delphi Programming

    More from About.com

    1. Home
    2. Computing & Technology
    3. Delphi Programming

    ©2008 About.com, a part of The New York Times Company.

    All rights reserved.