#define FILE_ATTRIBUTE_READONLY 0x00000001 LPARAMETERS cFileSpec, cNewAttribute IF PCOUNT() < 2 ; OR VARTYPE( cFileSpec ) # "C" OR VARTYPE( cNewAttribute ) # "C" ; OR EMPTY( cFileSpec ) OR EMPTY( cNewAttribute ) MESSAGEBOX( "Parameters: cFileSpec and cNewAttribute must be passed in." ) RETURN .F. ENDIF IF NOT FILE( cFileSpec ) MESSAGEBOX( "File: " + cFileSpec + ", not present." ) RETURN .F. ENDIF IF NOT INLIST( cNewAttribute, "+R", "-R" ) MESSAGEBOX( "cNewAttribute must be one of +R or -R" ) RETURN .F. ENDIF oFiler = CREATEOBJECT( "Filer.FileUtil" ) WITH oFiler .SearchPath = JUSTPATH( cFileSpec ) .FileExpression = JUSTFNAME( cFileSpec ) .Find( 0 ) && Search, discarding last collection. iCurrentAttribute = .Files.Item(1).Attr IF cNewAttribute = "-" *- Remove Read Only. iNewAtribute = BITAND( iCurrentAttribute, BITNOT( FILE_ATTRIBUTE_READONLY )) ELSE *- Add Read Only. iNewAtribute = BITOR( iCurrentAttribute, FILE_ATTRIBUTE_READONLY ) ENDIF .Files.Item(1).Attr = iNewAtribute ENDWITH RETURN .T.