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
 

FileGetAttr

unit
Sysutils
category
file management routines

declaration
function FileGetAttr(const sFileName: string): integer;

description
Retrieves the attributes of a specified file.

The resulting value 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
    FileSetAttr,


     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
    About.com Special Features

    Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

    Easy ways to connect two computers for networking purposes. More >

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

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

    All rights reserved.