Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete a hidden-readonly-system file
Message
From
21/11/2009 07:58:10
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01435925
Message ID:
01435926
Views:
100
This message has been marked as the solution to the initial question of the thread.
Chenge the attribute first
lcFile="yourfile.ext"
If Setattr(fullpath(lcFile)),'')
   erase (lcFile)
Else
   Messagebox("Can't delete "+lcFile)
Endif
   
FUNCTION SetAttr
PARAMETER zFileName, zAttribute
zAttribute = UPPER(zAttribute)
Private nAttribute
nAttribute=0
If 'S'$zAttribute && System
   nAttribute = nAttribute + 4
Endif    
If 'H'$zAttribute && Hidden
   nAttribute = nAttribute + 2
Endif    
If 'R'$zAttribute && ReadOnly
   nAttribute = nAttribute + 1
Endif    
If 'A'$zAttribute && Archive
   nAttribute = nAttribute + 32
Endif    
If 'N'$zAttribute && Normal
   nAttribute = nAttribute + 128
Endif    
declare integer SetFileAttributes IN kernel32 STRING, INTEGER 
Return SetFileAttributes(zFileName,nAttribute)=1
>Hi all
>
>I would like to delete a known file which has hidden-readonly-system attributes set from VFP. DELETE FILE does not seem to work. I have also tried to FCLOSE(FCREATE()) the file before the DELETE FILE call but still no joy.
>
>Please advise.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform