Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get the total numbers of files of a folder
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01055451
Message ID:
01055534
Views:
13
>We have tried =ADIR() function to the same but it give an error "Invalid subscript reference" or "subscript out of range".
>
>
>Thanks in advance
>Ravi Mehrotra
Ravi when I had to go beyound the ADIR limits, I made a cursor... This was code from VFP 6
PROCEDURE SubList
   CREATE CURSOR c_sFiles (FileName C(29), FileSize I, DateCreated T, ;
                 LastAccessed T, LastModified T )
   oFSO = CREATEOBJ('Scripting.FileSystemObject')
   oFolder = oFSO.GetFolder(cDirts)
   lnFiles = oFolder.Files.Count
   FOR EACH oFile IN oFolder.Files
      lcFileName = oFile.Name
      lnFileSize = oFile.Size
      lddatecreated = oFile.DateCreated
      ldlastAccess = oFile.DateLastAccessed
      ldlastmodified = oFile.DateLastModified
      INSERT INTO c_sFiles (FileName, FileSize, DateCreated, ;
                  LastAccessed , LastModified );
             VALUES( lcFileName, lnFileSize, ldDateCreated, ;
                   ldlastAccess, ldlastmodified) 
   ENDFOR  
   SELECT c_sFiles
   DO EntireDirect

PROCEDURE EntireDirect
   nDirNum= nDirNum+ 1
   cDirNum= ALLTRIM(TRANSFORM(nDirNum))
   SCAN
      gLogMESS= PADL(ALLTRIM(IIF(lSubDir,cDirNum,"*")),8," ")+ ;
                PADL(ALLTRIM(STR(RECNO())),7," ")+ " "+ ;
                PADR(cDirts+ FileName,50," ")+ DTOC(DateCreated)+ ;
                IIF(VAL(SYS(11,DATE()))- VAL(SYS(11,DateCreated))> lnDay," DELETED"," KEPT")
      IF !lDeleteThem
         gLogMess= gLogMess+ " TEST. No delete!" 
      ELSE
         IF VAL(SYS(11,DATE()))- VAL(SYS(11,DateCreated))> lnDay
            IF cDirty <> " "
               cDirectorySub= IIF(lSubDir, SUBSTR(cDirts,AT("\",cDirts,OCCURS("\",cDirts)-1)+1), "")
               IF !DIRECTORY(cDirty+ cDirectorySub)
                  sDirtyDirSub= cDirty+ cDirectorySub
                  MD &sDirtyDirSub
               ENDIF 
               IF !FILE(cDirty+ cDirectorySub+ ALLTRIM(FileName))
                  cmd2copy= "COPY FILE "+ cDirts+ ALLTRIM(FileName)+ " TO "+ cDirty+ cDirectorySub+ "*.*"
                  &cmd2copy
               ENDIF 
            ENDIF
            IF FILE(cDirty+ cDirectorySub+ ALLTRIM(FileName))
               DELETE FILE cDirts+ ALLTRIM(FileName)
               nDeleted= nDeleted+ 1
            ELSE 
               IF !EMPTY(cDirty)
                  gLogMess= " No Delete! Copy to New area failed. "+ ALLTRIM(FileName)
               ENDIF
            ENDIF
         ENDIF
      ENDIF 
      Do Write
It toke awhile to process - but it got the job done! (Archived and deleted old files)
Edgar L. Bolton, B.S. B.B.A.
Previous
Reply
Map
View

Click here to load this message in the networking platform