www.icetips.com  Icetips Utilities Documentation 5/9/2015    

Core Class: SetFileAttrib

Previous  Top  Next  


Prototype: (String pFile, <Byte pReadOnly>, <Byte pHidden>, <Byte pSystem>, <Long pAdditionalAttrib>),IT_DWORD,PROC

 

pFileThe filename to change attributes on.
pReadOnlySet the Read-Only attribute
pHiddenSet the Hidden attribute
pSystemSet the System attribute
pAdditionalAttribSet additional attributes.

 

ReturnsReturns 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:

GetFileAttrib

 

 

 



Direct link to this page: http://www.icetips.com/manuals/utilities/setfileattrib_core.htm