Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RD blows up on non-empty folders
Message
De
17/09/2012 16:43:42
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01553085
Message ID:
01553098
Vues:
50
You're welcome!

>Thanks !!
>
>>In my collection of tools I have a much enhanced version, which can change the attribute of every file in a directory tree:
>>**DO changetreeattr WITH 'c:\dir\*.*','N' && To reset
>>**DO changetreeattr WITH 'c:\dir\*.*','R' && Readonly
>>
>>Procedure changetreeattr
>>   Lparameters lcFileSkeleton, lcAttributes, lcCursor
>>   Local lcSelect As String, ;
>>      lnProcessed As Number
>>   Local lcAttributes1 As String
>>   lcSelect = Select()
>>   lnProcessed = 0
>>   lcAttributes1 = []
>>   Select 0
>>   If Pcount() < 3 Or Vartype(lcCursor) # [C]
>>      lcCursor = [curFiles]
>>   Endif
>>   Do RecurseDirectories With lcFileSkeleton, lcAttributes1, .F., lcCursor
>>   Scan
>>      setattr(Fullpath, lcAttributes)
>>   Endscan
>>   lnProcessed = Reccount()
>>   Use
>>   Select (lcSelect)
>>   Wait Clear
>>   Return lnProcessed
>>
>>****************************************
>>Procedure RecurseDirectories
>>   Lparameters lcFileSkeleton, lcAttributes, llKeepDirectory, lcCursor
>>   Local Array laDirectory[1, 1]
>>   Local lnFileCount As Integer
>>   Local lnCounter As Integer
>>   Local lcCurrentPath As Varchar(200)
>>   If Empty(llKeepDirectory)
>>      llKeepDirectory = .F.
>>   Endif
>>   If !llKeepDirectory
>>      Create Cursor (lcCursor);
>>         (Fullpath Varchar(200), filepath Varchar(200), filename Varchar(80), ext Varchar(4), filesize Integer, FullName Varchar(100),  ModiDate Date, ModiTime Char(16), FileAttr Char(6))
>>   Endif
>>   If Empty(lcFileSkeleton)
>>      lcFileSkeleton = [*.*]
>>   Endif
>>   If Empty(lcAttributes)
>>      lcAttributes = [DHS]
>>   Endif
>>   lnFileCount = Adir(laDirectory, lcFileSkeleton, lcAttributes)
>>   lcCurrentPath = Justpath(lcFileSkeleton)
>>   Wait [Processing: ] + Alltrim(lcCurrentPath) + [..hang on!] Window Nowait
>>   If lnFileCount > 0
>>      For lnCounter = 1 To lnFileCount
>>         If !Empty(Strtran(laDirectory[lncounter, 1], [.], []))
>>            If [D] $ laDirectory[lncounter, 5] && directory - need to recursively call!
>>               RecurseDirectories(Addbs(lcCurrentPath) + Addbs(Trim(laDirectory[lncounter, 1])) + Justfname(lcFileSkeleton), lcAttributes, .T., lcCursor)
>>            Else
>>               Insert Into (lcCursor) (Fullpath, filepath, FullName, filename, ext, filesize, ModiDate, ModiTime, FileAttr);
>>                  Values (Addbs(lcCurrentPath) +  laDirectory[lncounter, 1], lcCurrentPath, laDirectory[lncounter, 1], Juststem(laDirectory[lncounter, 1]), Justext(laDirectory[lncounter, 1]), laDirectory[lncounter, 2], laDirectory[lncounter, 3], laDirectory[lncounter, 4], laDirectory[lncounter, 5])
>>            Endif
>>         Endif
>>      Endfor
>>   Endif
>>   Return
>>****************************************
>>Function setattr
>>   Parameter tFileName, tAttribute
>>   tAttribute = Upper(tAttribute)
>>   Private nAttribute
>>   nAttribute = 0
>>   If [S] $ tAttribute && System
>>      nAttribute = nAttribute + 4
>>   Endif
>>   If [H] $ tAttribute && Hidden
>>      nAttribute = nAttribute + 2
>>   Endif
>>   If [R] $ tAttribute && ReadOnly
>>      nAttribute = nAttribute + 1
>>   Endif
>>   If [A] $ tAttribute && Archive
>>      nAttribute = nAttribute + 32
>>   Endif
>>   If [N] $ tAttribute && Normal
>>      nAttribute = nAttribute + 128
>>   Endif
>>   Declare Integer SetFileAttributes In kernel32 String, Integer
>>   Return SetFileAttributes(tFileName, nAttribute) = 1
>>
>>>With this little function you can easily change the attributes of your files, to not hidden in this case. A simple loop with adir() and this function will make every file visible.
>>>FUNCTION SetAttr
>>>PARAMETER tFileName, tAttribute
>>>tAttribute = UPPER(tAttribute)
>>>Private nAttribute
>>>nAttribute=0
>>>If 'S'$tAttribute && System
>>>   nAttribute = nAttribute + 4
>>>Endif    
>>>If 'H'$tAttribute && Hidden
>>>   nAttribute = nAttribute + 2
>>>Endif    
>>>If 'R'$tAttribute && ReadOnly
>>>   nAttribute = nAttribute + 1
>>>Endif    
>>>If 'A'$tAttribute && Archive
>>>   nAttribute = nAttribute + 32
>>>Endif    
>>>If 'N'$tAttribute && Normal
>>>   nAttribute = nAttribute + 128
>>>Endif    
>>>declare integer SetFileAttributes IN kernel32 STRING, INTEGER 
>>>Return SetFileAttributes(tFileName,nAttribute)=1
>>>
>>>>Hi Gang!
>>>>
>>>>If a folder is not empty, but has hidden files in it, what is the easiest way to REMOVE THIS FOLDER with VFP commands?? (If you try the following command, it throws an ERROR, since the folder is not empty).
>>>>
>>>>RD C:\PHARMACY\DOWNLOAD\DISK1\ and it has hidden files in it ??
>>>>
>>>>Thanks!
>>>>
>>>>PS.... if you use something other than VFP, can I be assured it will work with Windows 7 and 8 ??
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform