Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making a file Read-Only
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00322772
Message ID:
00322838
Views:
15
>Hi!
>
>Anyone knows if it is possible to set a file's Read-Only attribute in VFP6 SP3?
>
>Thanks!

Hi Sylvain,

In addition to what Cetin told you, the Windows Script Host File System object can do this with both files and folders
#define FILE_ATTRIBUTE_READONLY             0x00000001  
#define FILE_ATTRIBUTE_HIDDEN               0x00000002  
#define FILE_ATTRIBUTE_SYSTEM               0x00000004  
#define FILE_ATTRIBUTE_ARCHIVE              0x00000020  
#define FILE_ATTRIBUTE_NORMAL               0x00000080  
#define FILE_ATTRIBUTE_TEMPORARY            0x00000100  
#define FILE_ATTRIBUTE_OFFLINE              0x00001000  
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  0x00002000
oFSO = CREATEOBJECT('Scripting.FileSystemObject')
* lcfile is a valid file (it exists).
oFile = oFSO.GetFile(lcfile)
oFile.Attributes = BITOR(oFile.Attributes, FILE_ATTRIBUTE_READONLY)
* Set a folder as read-only
* lcfolder = is a valid folder
oFolder = oFSO.GetFolder(lcfolder)
lnmask = FILE_ATTRIBUTE_READONLY +;
  FILE_ATTRIBUTE_SYSTEM +;
  FILE_ATTRIBUTE_SYSTEM +;
  FILE_ATTRIBUTE_ARCHIVE
lnattributes = BITAND(oFolder.Attributes, lnmask)
oFolder.Attributes = BITOR(lnattributes, FILE_ATTRIBUTE_READONLY)
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform