GetDirectoryInfo()

Summary

Gets a listing of the contents of a directory.

Syntax

info = GetDirectoryInfo(string path, string type)

Argument Contents
path The full or partial path of the directory about which information is returned. Wildcards (? and *) may be used
type The type of directory entries to list: "All", "Directory", "Folder", or "File"

Returns

An array containing one element for each file or directory of the indicated type in specified path. Each element is an array of eight items:

Element Type Contents
1 String Filename, including extension, but not including the path
2 String Type of file ("directory", "file", or "volume id")
3 String Allowable access to the file ("read only", or "read/write")
4 String State of the file ("hidden" or "not hidden")
5 String System state of the file ("system" or "not system")
6 Real Size of the file in bytes
7 String Date of the file
8 String Time of the file

Notes

  • Directory and Folder mean the same thing.

  • For more information on full and partial paths, see Identifying Files and Folders.

  • GetDirectoryInfo() returns null if there are no directory entries of the indicated type in the path.

  • If the type of directory entries to list is "Directory" then wildcards (? and *) must be used to have the list of directories returned.

  • The size of the file is returned as a real number to handle very large files, and may not give the exact size.

Examples

// Get file information
di = GetDirectoryInfo("c:\\geofiles\\*.CDF", "File")
// Assemble a list of names and sizes
dim file_names[di.length]
total_size = 0
for i = 1 to di.length do
file_names[i] = di[i][1]
total_size = total_size + di[i][6]
end
// Get directory information
di = GetDirectoryInfo("c:\\geofiles\\*", "Directory")
// Choose a folder and get information on its subfolders
in_path = ChooseDirectory("Choose a folder", )
dirs = GetDirectoryInfo(in_path+"\\*.*", "Folder")

Error Codes

Error Type Meaning
Error The type is invalid or an error occurred while reading the file information

See Also

Function Summary
ChooseDirectory() Gets the path name to an existing directory/folder
ChooseDirectory() Gets the path name to an existing directory/folder
FileCheckUsage() Checks whether files are in use by Maptitude.
GetFileInfo() Gets information about a file
GetDrives() Returns a list of disk drives and their type
SearchFilePath() Searches for the path for a filename
SetFileAttributes() Changes the attributes of a file or a directory