'============================================================================ ' MakeDir - Create the specified directory if it does not exist. Will create ' nested directories if they do not exist. ' ' Directory$ - Full pathspec for the directory to create ' SUB MakeDir(BYVAL Directory$) PUBLIC Directory$ = RTRIM$(Directory$, "\") 'trim trailing backslash Backslash = INSTR(Directory$, "\") 'locate first backslash DO IF Backslash THEN 'nested directories Tmp$ = LEFT$(Directory$, Backslash-1) 'extract next dir ELSE Tmp$ = Directory$ END IF IF NOT Exist(Tmp$+"\NUL") THEN 'directory doesn't exist IF (Backslash = 1) OR (RIGHT$(Tmp$, 1) = ":") THEN 'drive doesn't exist EXIT SUB END IF MKDIR Tmp$ 'create final directory END IF IF Backslash THEN 'more subdirectories Backslash = INSTR(Backslash+1, Directory$, "\") 'keep going ELSE EXIT DO 'all done END IF LOOP END SUB