Delete File





QuickBasic


' DOS 2+ - UNLINK - DELETE FILE

'$INCLUDE: 'qb.bi'

DIM filename AS STRING
DIM inregs  AS RegTypeX
DIM outregs AS RegTypeX

filename = "C:\INT\123.txt" + CHR$(0)
inregs.DS = VARSEG(filename)
inregs.DX = SADD(filename)
inregs.AX = &H4100
inregs.CX = &H0  ' attribute mask for deletion

' DOS interrupt with sub-function &H41

CALL InterruptX(&H21, inregs, outregs)

IF outregs.FLAGS AND 1 THEN
   PRINT "Error deleting >> " + filename
   BEEP: END
END IF

PRINT filename; " deleted!"