From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Subject: Re: Deleting all files on a floppy Date: 24 Apr 1999 00:00:00 GMT Message-ID: Content-Transfer-Encoding: 8bit References: <372097D6.E98315A1@profitsys.sk.ca> Content-Type: text/plain; charset=iso-8859-1 Organization: TeamB Mime-Version: 1.0 Reply-To: 100113.1101@compuXXserve.com Newsgroups: borland.public.delphi.objectpascal In article <372097D6.E98315A1@profitsys.sk.ca>, David Heagy wrote: > I need to delete all files on a floppy (including directories) in delphi > 1. Does anyone know how? > The fastest way is in fact to perform a quick format on the diskette. Since there is no simple API to do that available you simply WinExec format: Winexec('format.com A: /Q', SW_SHOW ); However, this forces the user to respond to the prompts format issues. You can prevent this by preparing two files. The first is a response file that contains the answers to the prompts: two empty lines and one line with a 'n' in it: Procedure WriteResponsefile; Var f: System.Text; Begin System.Assign( f, 'resp.txt' ); Rewrite(f); WriteLn(f); WriteLn(f); WriteLn(f,'n'); System.Close( f ); End; The second is a batch file that you then launch: Procedure Quickformat_Drive_A; Const batch = 'qf_a.bat'; Var f: System.Text; Begin WriteResponseFile; System.Assign( f, batch ); Rewrite(f); WriteLn(f, 'format A: /Q < resp.txt' ); WriteLn(f, 'del resp.txt' ); Write( f, 'del %0' ); { Note: no newline! } System.Close(f); WinExec( batch, SW_HIDE ); End; This uses the "self-immolating batchfile" approach . A batch can delete itself, different from a running EXE. The files are generated in whatever happens to be the current directory. It would probably be smart to set that to the windows TEMP directory first, that is guaranteed to be writeable. I tested this with D3/Win95B (no D1 on this crate). I don't remember if the Win 3.1 WinExec was smart enough to execute batch files, you may have to get the command interpreter from the COMSPEC environment variable (see getEnvVar in windos.pas, copy this routine, do not use the unit!) and execute that with a commandline of '/C '+batch. Peter Below (TeamB) 100113.1101@compuserve.com) No e-mail responses, please, unless explicitely requested!