FileInfoToArray

Returns information on a set of files, as an array.

Syntax:

FileInfoToArray( file-list [, flags])

Parameters:

(s) file-list specifies a list of filenames, which may be wildcarded. (example: "*.jpg|*.bmp")

(i) flags [optional] can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:
Value
 Meaning
1 Return file sizes as huge numbers. This is a long decimal number string, which may represent a number too large to be converted to an integer.

2 Return file names with full paths

4 Return file sizes as 64-bit integers.

Returns:

(a)  2-dimension array

 

This function creates and returns a 2-dimension array. There are [n + 1] rows in the array, where 'n' is the number of files that were returned. Each row has 7 columns. The first row (row 0) is a header containing summary information. Each subsequent row contains information about one returned file. The columns are as follows:

 

Header row:

Column

Value

0

number of files returned

1

total size of files returned. If flag is zero and total size is greater than max signed integer, the function will return a floating point number.

2-6

(unused, set to 0)

 

Other rows:

Column

Value

0

file name

1

file size

2

file last modified time, in YmdHms format

3

file last accessed time, in YmdHms format

4

file created time, in YmdHms format

5

file attribute string in the form "RASH" (see FileAttrGet)

6

file attribute bitmask (see FileAttrGetEx)

 

This function converts a file time to local time using the users current settings for the time zone and daylight saving time. You must take care when using file times if the user has set the system to automatically adjust for daylight saving time. However, you can us  IntControl 102 to have the function return file times as UTC time. Also see FileCompare.

This function supports extended-length path names.

Example:


filelist = StrCat(ShortCutDir("Personal",0,@TRUE),"*.*")
infoarray = FileInfoToArray(filelist, 1|2)
infostr = StrCat("Number of files: ",infoarray[0,0],@CRLF)
infostr = StrCat(infostr,"Total size of files: ",infoarray[0,1],@CRLF,@CRLF)
For xx = 1 To infoarray[0,0]
   infostr = StrCat(infostr,"File Name: ",infoarray[xx,0],@CRLF)
   infostr = StrCat(infostr,"File Size: ",infoarray[xx,1],@CRLF)
   infostr = StrCat(infostr,"Last Modified: ",infoarray[xx,2],@CRLF)
   infostr = StrCat(infostr,"Last Accessed: ",infoarray[xx,3],@CRLF)
   infostr = StrCat(infostr,"Created: ",infoarray[xx,4],@CRLF)
   infostr = StrCat(infostr,"Attribute: ",infoarray[xx,5],@CRLF)
   infostr = StrCat(infostr,"Attribute Bitmask: ",infoarray[xx,6],@CRLF)
   infostr = StrCat(infostr,@CRLF)
Next
tmpfile = FileCreateTemp("TMP")
FilePut(tmpfile, infostr)
AskFiletext("File Data",tmpfile,@UNSORTED,@SINGLE,@FALSE)
FileDelete(tmpfile)
Exit
See Also:

FileItemize, FileAttrGet, FileAttrGetEx, FileTimeGet, FileTimeGetEx, FileSize, FileSizeEx