File.GetAttributes

table File.GetAttributes ( 

string Filename )

Example 1

all_attributes = File.GetAttributes(_ProgramFilesFolder.."\\My Program Folder\\MyProgram.exe");

Stores all of the attributes of the file named "MyProgram.exe" in a table called "all_attributes."

Note: _ProgramFilesFolder is a built-in variable that contains the path to the user's Program Files directory.

Example 2

attrib = File.GetAttributes( _TempFolder .. "\\MyTempFile.tmp" );
bReadOnly = attrib.ReadOnly;
strCreationDate = attrib.CreationDate;

Stores the attributes of the MyTempFile.tmp file located in the user's temp folder in a table named attrib, then copies the ReadOnly attribute into a boolean variable named bReadOnly, and copies the file's creation date string into a variable named strCreationDate.

Example 3

-- Get the file attributes from MyTempFile.tmp, located in the temp directory
attrib = File.GetAttributes( _TempFolder .. "\\MyTempFile.tmp" );

if attrib.ReadOnly then
    -- The file is read only, alert the user
    Dialog.Message("Read-Only", "The file you are trying to access is read only.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end

Retrieves the attributes of the file "MyTempFile.tmp" and alerts the user if the file has it's read-only attribute set.

See also:  Related Actions