Neat way of getting files

Posted by jmls on 16-Sep-2008 14:30

This may be quite useful to people: Shows how to get all the files matching a pattern in the directory and all subdirectories

USING System.IO.*.

DEF VAR myfiles AS CHAR EXTENT .

MyFiles = Directory:GetFiles("c:\temp", "*.jpg", SearchOption:AllDirectories).

MESSAGE EXTENT(MyFiles) SKIP MyFiles[1] VIEW-AS ALERT-BOX.

All Replies

Posted by WJCPvanBeek on 14-Dec-2015 05:16

This works just fine, except when Directory:GetFiles returns a valid, yet empty string array. In that case you will get an error assigning this to the MyFiles extent: "Uninitialized array used as source of assignment. (14906)".

One way out of this is to check if Directory:GetDirectories(...):Length = 0.

This thread is closed