Jump to content
Henry Olive

Folder - ReadOnly, Hidden, Normal

Recommended Posts

Good Day

 

I want to make a **Folder**  ReadOnly or Hidden  and then change to Normal

I tried below codes for ReadOnly and Normal but i got below err.msg

var
    attributes: TFileAttributes;

  attributes := TFile.GetAttributes(CDS1FOLDERPATH.AsString);

 

  ReadOnly : 

  Include(attributes, faReadOnly);  // ERROR  E2010 Incompatible types: 'TFileAttribute' and 'TFieldAttribute'
  TFile.SetAttributes(CDS1FOLDERPATH.AsString, attributes);

 

  Normal :
  Exclude(attributes, faReadOnly);
  TFile.SetAttributes(CDS1FOLDERPATH.AsString, attributes);


Hidden :

 


 

Share this post


Link to post

The Data.DB and System.IOUtils units both define an identifier named faReadOnly (as a member of TFieldAttribute and TFileAttribute, respectively). The error message means both units are in scope and the compiler doesn't know which one you want to use. So you will have to qualify it explicitly, eg:

 

Include(attributes, TFileAttribute.faReadOnly);

 

Exclude(attributes, TFileAttribute.faReadOnly); 

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×