cs40sc30@CSUFRES.CSUFRESNO.EDU (Mika Toikka) (08/16/89)
How does one delete files or directories in MS-DOS from Pascal, if this is possible? I am trying to write a program that does something like the 'rm -rf *' (recursively delete all contents of directory) of Unix. I'm pretty sure that the MS-DOS batch-file language is unsuited to this task, so I'm trying to use Pascal. Please e-mail me. I'll summarize to the net if there's interest. David Choweller InterNet: davec@csufres.csufresno.edu UUCP: davec@csuf3b.UUCP
mg2n+@andrew.cmu.edu (Martin G. Greenberg) (08/17/89)
If you're using Turbo Pascal, it's relatively easy to erase a given file: The code below will erase the file named "demo.foo" provided the file is not read only. PROCEDURE Demo; VAR File2Kill : Text; (* Declaring as text will allow any file to be erased *) BEGIN Assign (File2Kill, 'DEMO.FOO'); Erase (File2Kill) END; As to erasing an entire directory and/or subdirectories, you could use Turbo's "FileFind" procedure/function and a while loop to erase the whole directory. Hope this helps. MGG