Reading disk directories.

 BBS: SPOKANE CENTRAL
Date: 05-20-93 (14:06)             Number: 39
From: GOODGUY #22 @5290 VIRTUAL    Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Reading disk directories.      Conf: (18) QuickBASIC

0R: net33: @5912 (via @1042) [23:04 05/27/93] 0R: net33: @6850 (via @6852) [22:09 05/26/93] T#@> Hello. I am a Quick BASIC and a Visual BASIC programmer. In one of m T#@>resent programs, I need to know the names of all the directories on my hard T#@>disk (put them in an array). Before, I just did this: I assume that you are using Basic rather than Visual Basic because all that stuff is redily available in list boxes in VB. I think in Basic the "Files" procedure will retrieve the file names but not Sub's, is that right? I'll give you the Basic routine I found and Assembler routines testing for SubDirectorys and let you go from there. I know, it's assembler but everything of value takes a little work (Translate, test) at least, right? 100 'Load the directory sectors at &H2000 and then... 110 DEF SEG=&H2000 'point to start of directory data 120 FILENAMES$="NEWDATAAAA" 'search for filename without "." 130 DIRPTR=0 'pointer to a directory 140 FOR N=1 TO 112 'check each entry 150 X$="" 'temporary string to hold filename 160 FOR M=0 TO 10 'for each character of filename... 170 X$=X$+PEEK(DIRPTR+M) 'add it to the temporary string X$ 180 NEXT M 190 IF X$-FILENAME$ THEN 220 'compare filenames, jump if match 200 NEXT N 210 PRINT "FILE NOT FOUND":END 'no match found, give error message 220 X=PEEK(DIRPTR+11) 'match found get attribute byte 230 IF X AND 32 <> 0 THEN PRINT "FILE NOT BACKED UP" 240 IF X AND 16 <> 0 THEN PRINT "FILE IS A SUBDIRECTORY" 250 IF X AND 8 <> 0 THEN PRINT "FILE IS A VOLUME LABEL" 260 IF X AND 4 <> 0 THEN PRINT "FILE IS A SYSTEM FILE" 270 IF X AND 2 <> 0 THEN PRINT "FILE IS A HIDDEN FILE" 280 IF X AND 1 <> 0 THEN PRINT "FILE IS A READ ONLY FILE" 'I think you'll have to change the current directory in order to test subdirectories for sub.... if that doesn't work then here's a snippet the Assembler code for testing a file for the subdir attribute ; TEST ATTRIBUTE BYTE FOR SUBDIRECTORY ;---In the Data Segment PATH DB "File name to be tested in ascii0 format" ; end it with a "0" ;---In the code segment MOV AH,43H ;Get/set attribute function MOV AL,0 ;Get the attribute byte (1 = set byte) LEA DX,PATH ;Point DS:DX to the files path INT 21H ;Get attribute byte and put it in CX JC ERROR_ROUTINE ;On error go to your recovery routine CMP CL,00010000B ;Test bit 4 for subdir ; Bit ; 0 = read only ; 1 = hidden ; 2 = system ; 3 = volume label ; 4 = subdirectory ; 5 = backup bit ; 0 and rest are not used You'll probably have gotten a better answer by now but thought I'd throw this in just incase. Hope it helps... $$ The Heart of Gold (HOG) BBS 1(408)732-8958 @1408000-VirtualNET @4080-HOGnet Sysop: friday jones Sunnyvale, California USA VBBS 6.00 USR V32/V42BIS "Where the rats have more delectibly-delicious CRUNCH!" 0 0Via: 1408005*1 6160*1 5092*1
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET