Mega Code Archive

 
Categories / Delphi / Examples
 

Remove readonly flag from file

The following function will attempt to remove the read only flag on a file, you will need the function in this article (http://www.howtodothings.com/ViewArticle.aspx?Article=755). function RemoveReadOnly(const FileName: string): Boolean; begin (* Assume Success *) Result := True; (* Make sure the file is read only before we try and change the attributes *) if (IsReadOnly(FileName)) then begin SetFileAttributes(PChar(FileName), FILE_ATTRIBUTE_NORMAL); Result := not IsReadOnly(FileName); end; end;