DEFINE CLASS Dir_Tree AS CUSTOM nargs = 0 cdrive = "" DIMENSION a_dirs[1, 1] a_dirs[1, 1] = "" CurrDir = "" PROCEDURE Init LPARAMETER pcdrvltr LOCAL lcdriveltr This.nargs = PARAMETERS() lcdriveltr = pcdrvltr IF This.nargs = 0 OR EMPTY(pcdrvltr) This.cdrive = 'C:\' ELSE IF LEN(lcdriveltr) = 1 lcdriveltr = lcdriveltr + ":" ENDIF This.cdrive = AddBS(lcdriveltr) ENDIF This.CurrDir = SYS(5) + CURDIR() RETURN PROCEDURE LoadTree LPARAMETER padirs, pcstartdir EXTERNAL ARRAY padirs LOCAL lni, lnlast, lnargs, a_dir lnargs = PARAMETERS() DIMENSION a_dir[1] IF lnargs = 1 SET DEFAULT TO (This.cdrive) lnlast = ADIR(a_dir, "", 'D') IF LEN(This.cdrive) > 3 * We're not starting at the root = ADEL(a_dir, 1) = ADEL(a_dir, 1) lnlast = lnlast - 2 DIMENSION a_dir[lnlast, 5] ENDIF DIMENSION This.a_dirs[lnlast, 5] = ACOPY(a_dir, This.a_dirs) lni = 0 DO WHILE lni < lnlast lni = lni + 1 This.LoadTree(@a_dir, This.a_dirs[lni, 1]) lnlast = ALEN(This.a_dirs, 1) ENDDO DIMENSION padirs[lnlast, 5] = ACOPY(This.a_dirs, padirs) ELSE SET DEFAULT TO (This.cdrive + pcstartdir) lnlast = ADIR(a_dir, "", 'D') IF lnlast > 2 * Remove the first two elements * which contain "." and ".." * (the entry for the current directory * and its parent) = ADEL(a_dir, 1) = ADEL(a_dir, 1) lnlast = lnlast - 2 DIMENSION a_dir[lnlast, 5] FOR lni = 1 TO lnlast a_dir[lni, 1] = AddBS(pcstartdir) + a_dir[lni, 1] NEXT lnorglen = ALEN(This.a_dirs, 1) DIMENSION This.a_dirs[lnorglen + lnlast, 5] lnelenum = AELEMENT(This.a_dirs, lnorglen + 1, 1) = ACOPY(a_dir, This.a_dirs, 1, -1, lnelenum) ENDIF ENDIF SET DEFAULT TO (This.CurrDir) RETURN ENDDEFINEWhen you CREATEOBJECT(), passing the starting directory as a parameter. Then call the LoadTree() method with a dummy array. The results will be in the object's a_dir member, and will not include the starting directory.