Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set file attribute?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00823333
Message ID:
00823390
Views:
16
>>I found this API to set a file attribute
>>
>>
>>
DECLARE SHORT SetFileAttributes IN kernel32;
>>    STRING lpFileName,;
>>    INTEGER dwFileAttributes
>>
>>
>>I assume I set lpFilename to xyz.doc
>>but what do I set dwFileAttributes to make xyz.doc read only?

>
>Peter
>
>Another way is by using WSH:
>
>#define READONLY 1
>#define HIDDEN 2
>#define SYSTEM 4
>#define ARCHIVE 32
>oFSO = CreateObject("Scripting.FileSystemObject")
>oFile = oFSO.GetFile("c:\xyz.doc")
>oFile.Attributes = READONLY && changes to RO
>
Alex,

It's better to use the bit manipulation functions. This is because on of the file attribute bits is, itself, read-only (FILE_ATTRIBUTE_DIRECTORY 0x10) and may cause an error. Further, setting the attributes directly clears the other bits such as the archive bit.
George

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

Click here to load this message in the networking platform