File dates and attributes

Everything else that doesn't fall into one of the other PB categories.
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

File dates and attributes

Post by Dreglor »

i want to know how to get the date (modified only)
and any attibutes the file had
and is it possible to set these?
~Dreglor
AlGonzalez
User
User
Posts: 53
Joined: Sun Feb 15, 2004 6:04 am
Location: Easley, SC, USA

Post by AlGonzalez »

For date information, look into the "GetFileTime_" and "FileTimeToSystemTime" Windows API calls.

Get/Set Attributes:

Code: Select all

Procedure.s ShowFileAttributes(file.s)
    Protected result.l, attribs.s
    
    result = GetFileAttributes_(file)

    attribs.s = ""
    If result & #FILE_ATTRIBUTE_DIRECTORY 
        attribs + "D"
    EndIf
    If result & #FILE_ATTRIBUTE_COMPRESSED 
        attribs + "C"
    EndIf
    If result & #FILE_ATTRIBUTE_READONLY 
        attribs + "R"
    EndIf
    If result & #FILE_ATTRIBUTE_ARCHIVE 
        attribs + "A"
    EndIf
    If result & #FILE_ATTRIBUTE_SYSTEM
        attribs + "S"
    EndIf
    If result & #FILE_ATTRIBUTE_HIDDEN 
        attribs + "H"
    EndIf
    
    ProcedureReturn attribs
EndProcedure

fn.s = "C:\selects.txt"
Debug ShowFileAttributes(fn)  ; result A
SetFileAttributes_(fn, #FILE_ATTRIBUTE_READONLY | #FILE_ATTRIBUTE_ARCHIVE | #FILE_ATTRIBUTE_SYSTEM | #FILE_ATTRIBUTE_HIDDEN)
Debug ShowFileAttributes(fn)  ; result RASH
SetFileAttributes_(fn, #FILE_ATTRIBUTE_ARCHIVE)
Debug ShowFileAttributes(fn)  ; result A
You may also want to look at the "DirectoryEntryAttributes" command.

HTH
Post Reply