INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Windows Scripting

How to get all file information in a directory by mgagnon
Posted: 9 Sep 03

This requires a Windows Scripting version 5.6 or more.
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

This code was adapted to VFP from a sample found in the Windows Scripting documentation.


oFolder = GETDIR()
GenerateAllFolderInformation(oFolder)
FUNCTION GenerateAllFolderInformation
   LPARAMETERS loFolder
   #DEFINE TABSTOP CHR(9)
   #DEFINE NewLine CHR(13)
   PUBLIC  lcText
   LOCAL lcSubFolders
   LOCAL lcSubFolder
   LOCAL lcFiles
   LOCAL lcFile
   FSO = CREATEOBJECT("Scripting.FileSystemObject")
   lcFolder = FSO.getfolder(loFolder)
   lcText = "Folder:" +TABSTOP+ lcFolder.PATH+ NewLine+ NewLine
   lcFiles = lcFolder.FILES
   IF lcFiles.COUNT =1
      lcText = "There is 1 file" & NewLine
   ELSE
      lcText = lcText+ "There are " +TRANSFORM(lcFiles.COUNT)+ " files" +NewLine
   ENDIF

   IF lcFiles.COUNT <> 0
      FOR EACH lFile IN lcFiles
         GenerateFileInformation(lFile)
      NEXT
   ENDIF
   STRTOFILE(lcText,"c:\fileinfo.txt")
   MODIFY FILE c:\fileinfo.txt
FUNCTION GenerateFileInformation
   LPARAMETERS lcFile
   lcText = lcText+NewLine + "Path:" + TABSTOP + lcFile.PATH
   lcText = lcText+NewLine + "Name:" + TABSTOP + lcFile.NAME
   lcText = lcText + NewLine + "Type:" + TABSTOP + lcFile.TYPE
   lcText = lcText + NewLine + "Attribs:" + TABSTOP + ShowFileAttr(lcFile)
   lcText = lcText + NewLine + "Created:" + TABSTOP + DTOC(lcFile.DateCreated)
   lcText = lcText + NewLine + "Accessed:" + TABSTOP + DTOC(lcFile.DateLastAccessed)
   lcText = lcText + NewLine + "Modified:" + TABSTOP + DTOC(lcFile.DateLastModified)
   lcText = lcText + NewLine + "Size" + TABSTOP + TRANSFORM(lcFile.SIZE) + NewLine
ENDFUNC
FUNCTION ShowFileAttr
   LPARAMETER llcFile
   ATTR = llcFile.ATTRIBUTES
   DO CASE
      CASE ATTR = 0
         ShowFileAttr = "Normal"
      CASE ATTR =1
         ShowFileAttr = "Read-Only"
      CASE ATTR  = 2
         ShowFileAttr = "Hidden"
      CASE ATTR  = 4
         ShowFileAttr = "System"
      CASE ATTR  = 8
         ShowFileAttr = "Volume"
      CASE ATTR  = 16
         ShowFileAttr = "Directory"
      CASE ATTR  = 32
         ShowFileAttr = "Archive"
      CASE ATTR = 64
         ShowFileAttr = "Alias"
      CASE ATTR = 128
         ShowFileAttr = "Compressed"
   ENDCASE
   RETURN ShowFileAttr
ENDFUNC


Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close