Mega Code Archive

 
Categories / Delphi / Examples
 

Detect if file is readonly

The following function will return True if a file is read only. function IsReadOnly(const FileName: string): Boolean; var sr: TSearchRec; begin (* Assume not read only *) Result := False; if FindFirst(FileName, faAnyFile, sr) = 0 then begin Result := (sr.Attr and faReadOnly) <> 0; FindClose(sr); end; end;