|
Previous Top Next |
Prototype: | (String pFile, <Byte pReadOnly>, <Byte pHidden>, <Byte pSystem>, <Long pAdditionalAttrib>),IT_DWORD,PROC |
pFile | The filename to change attributes on. |
pReadOnly | Set the Read-Only attribute |
pHidden | Set the Hidden attribute |
pSystem | Set the System attribute |
pAdditionalAttrib | Set additional attributes. |
Returns | Returns 0 if the function failed and non-zero value if it succeeded. |
This method changes the attributes of the specified file. If only the filename is specified or the pReadOnly, pHidden and pSystem are all set to zero the attribute is set to FILE_ATTRIBUTE_ARCHIVE. The example below is from the CoreClassDemo.app and demonstrates the use of variables to set the attributes. The demo app also shows how to retrieve the attributes when a file is selected and set the variables. We suggest you study the code in the demo application.
Example:
ITC ITCoreClass
S CString(256)
Code
If Not Loc:AttribFile
Post(EVENT:Accepted, ?LookupFile)
Exit
End
If Loc:ReadOnly+Loc:Hidden+Loc:System > 0
If Loc:ReadOnly
S = ' +ReadOnly'
End
If Loc:Hidden
S = S & ' +Hidden'
End
If Loc:System
S = S & ' +System'
End
S = 'to' & S
Else
S = ' back to Archive Only'
End
If Message('Are you sure that you want to change the attributes for "' & Clip(Loc:AttribFile) &|
'" ' & S &|
'?||Note that you may need to change your Windows Explorer settings to see Hidden and System files!!!',|
'SetFileAttrib',|
ICON:Question,BUTTON:Yes+BUTTON:No,BUTTON:No) = BUTTON:Yes
If Not ITC.SetFileAttrib(Loc:AttribFile,Loc:ReadOnly,Loc:Hidden,Loc:System)
Message('Could not set the attributes on the file:||' & ITW.GetLastAPIError())
End
End
See also: