Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OFSO = CREATEOBJECT('Scripting.FileSystemObject') not wo
Message
From
23/07/2012 09:49:41
 
 
To
23/07/2012 09:40:57
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01548984
Message ID:
01549002
Views:
57
>>Yes, I came back three months ago. Being away from my family made me homesick.
>>
>I can understand that.
>but now back to my problem
>I use you code like that:
>
>
>nAttribute=1
>declare integer SetFileAttributes IN kernel32 STRING, INTEGER 
>x1=SetFileAttributes(thisform.lcFilename,nAttribute)
>
>it returns 1 in x1
>but he read only flag does not change :-((
>
>peter

That's strange, I have never had any problems with it, Maybe it will return the wrong value if the file in question is in use by another value? Or maybe the OS needs some time to release the file handle? Try to use SetAttr and GetAttr in a little loop with for instance five tries and a little delay before it gives up.

Here's my corresponding GetAttr function:
Function GetAttr
   Parameter zFileName && This is a complete filespec.

   Private zADIR, zReturn, zAReturn, zAttribute, zForNext, zAt

   zAReturn = Adir(zADIR, zFileName,'rhsa')
   zReturn = ''

   If zAReturn = 1 && check for bad filename
      zAttribute = zADIR[5] && get our attributes
      For zForNext = 1 To 5 && Loop through attribs
         zAt = Substr(zAttribute,zForNext,1) && pull out 1 char
         If zAt != '.' && skip 'blanks'
            zReturn = (zReturn + zAt) && set the return up
         Endif
      Endfor
   Else
      zReturn = '?' && Indicate a bad filename
   Endif

Return (zReturn)
Previous
Reply
Map
View

Click here to load this message in the networking platform