Your check is wrong. Here is a correct version:Code: Pascal [Select][+][-]uses SysUtils; function IsDirectoryReadOnly(const DirName: string): Boolean;var SR: TSearchRec;begin if FindFirst(DirName, faAnyFile, SR) = 0 then begin Result := (SR.Attr and faReadOnly) <> 0; FindClose(SR); end else Result := False;end;
Code: Pascal [Select][+][-]function CheckIfFolderIsReadOnly(FolderPath: String): Boolean;var FolderInfo: TSearchRec; SelectedNode: TTreeNode;begin // Get the selected node SelectedNode := Browser.myTreeView.Selected; if Assigned(SelectedNode) then begin // remove last delimiter LeftStr(FolderPath, (length(FolderPath)-1)); // Check if the folder exists if DirectoryExists(FolderPath) then begin // Check if the folder is read-only if FindFirst(FolderPath, faAnyFile, FolderInfo) = 0 then begin Result:= (FolderInfo.Attr and faReadOnly) <> 0; FindClose(FolderInfo); end else Result:= False; end; end;end;
This looks weird to meCode: Pascal [Select][+][-]Result:= (FolderInfo.Attr and faReadOnly) <> 0; Would have expectedCode: Pascal [Select][+][-]Result:= (FolderInfo.Attr and faReadOnly) = faReadOnly;
..........Would have expectedCode: Pascal [Select][+][-]Result:= (FolderInfo.Attr and faReadOnly) = faReadOnly;