Henry Olive 5 Posted November 6 Good Day I want to make a FOLDER Hidden then turn to Normal but i get an error (error point below) What am i doing wrong ? Thank You procedure TFolderss.btnHiddenClick(Sender: TObject); var FileName : String; attributes: TFileAttributes; begin FileName := FoldersFOLDERPATH.AsString; attributes:= TFile.GetAttributes(FileName); Include(attributes,TFileAttribute.faHidden); Here i get [dcc64 Error] UFolders.pas(103): E2003 Undeclared identifier: 'attributes ' TFile.SetAttributes(FileName, attributes); end; procedure TFolderss.btnNormalClick(Sender: TObject); var FileName : String; attributes: TFileAttributes; begin FileName := FoldersFOLDERPATH.AsString; attributes:= TFile.GetAttributes(FileName); Exclude(attributes,TFileAttribute.faNormal); TFile.SetAttributes(FileName, attributes); end;; Share this post Link to post
Lajos Juhász 293 Posted November 6 You have some hidden unicode character there. It can happen if you copy paste from the internet. var FileName : String; attributes: TFileAttributes; begin FileName := 'Test'; attributes:= TFile.GetAttributes(FileName); Include(attributes, TFileAttribute.faHidden); TFile.SetAttributes(FileName, attributes); end; This compiles. Share this post Link to post
Henry Olive 5 Posted November 6 This time i get below error msg FileName :='C:\TEST PROG -> This is FOLDER not FILE attributes:= TFile.GetAttributes(FileName); // Error Msg = The specified file was not found Could be there is still any hidden unicode character ? ( My Form FileFormat shows ANSI ) Thank You Share this post Link to post
Lajos Juhász 293 Posted November 6 No, a file is a file a folder is a folder two different things. In case of a folder you should use the TPath (record). attributes:=TPath.GetAttributes(PathName) Share this post Link to post