PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Displaying in a List Box control the short names of the files present in a directory
fShortName (Example)
Displaying in a List Box control the short names of the files present in a directory
The following code is used to:
  • store in an array the name of the files found in a directory (ArrayPath),
  • display in a List Box control the short names of the files present in a directory (LIST_ListShortName).
// Declare and initialize the variables
PathDirFile is string
ResShortName is string
ArrSubscript is int = 0 // Subscript of the array
LoopSubscript is int
ArrayPath is array
 
// Retrieve the first file found in the directory
PathDirFile = fDir("C:\MyDirectories\*.*", frFile)
WHILE PathDirFile <> "" THEN
// Increment the array subscript
ArrSubscript++
// Include the names of the files in the array
ArrayPath[ArrSubscript] = PathDirFile
// Retrieve the next file
PathDirFile = fDir("")
END
 
FOR LoopSubscript = 1 TO ArrSubscript
// Retrieve the short name
ResShortName = fShortName(ArrayPath[LoopSubscript])
IF ResShortName = "" THEN
// Display an error message if the retrieval was not performed
Error(ErrorInfo(errMessage))
ELSE
// Display short name in a List Box control
ListAdd(LIST_ListShortName, ResShortName)
END
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment