picture

Remove Read Only Property of a File.

Recently I wrote a custom installer program and burned it to a CD together with particular files. After coping the files from the CD to the hard drive some files were set by Windows to read only. Below is the function to remove read only property of a file:


procedure RemoveFileAttributes(const FileName: String);
begin
  try
    if FileExists(FileName) then
      Windows.SetFileAttributes(PChar(FileName),
                    FILE_ATTRIBUTE_NORMAL);
  except
    ShowMessage('Datei ' + FileName +
          #10#13 + 'konnte nicht zum Lesen freigegeben werden!');
  end;
end;

Leave a Reply

You must be logged in to post a comment.