Delete 
Author Message
 Delete

Hi,

How to erase a repertory with all the files included in this repertory in
TP6.

Thank



Wed, 18 Jun 1902 08:00:00 GMT  
 Delete
Quote:

>Hi,

>How to erase a repertory with all the files included in this repertory in
>TP6.

>Thank

Jacques,

I assume when you say "repertory" you mean "directory". You can clear a
directory in two ways:

- You can shell out to DOS, then execute the DELTREE command:
  exec(getenv('comspec'), '/c deltree /y c:\xxx')
- You can use FindFirst/FindNext followed by the "erase" command for each
file you find.

Note that there is a difference between the two methods: DELTREE will delete
the whole directory tree c:\xxx. ERASE will only delete files.

Klaus



Wed, 18 Jun 1902 08:00:00 GMT  
 Delete

Quote:

>I assume when you say "repertory" you mean "directory". You can clear a
>directory in two ways:

>- You can shell out to DOS, then execute the DELTREE command:
>  exec(getenv('comspec'), '/c deltree /y c:\xxx')
>- You can use FindFirst/FindNext followed by the "erase" command for each
>file you find.

>Note that there is a difference between the two methods: DELTREE will delete
>the whole directory tree c:\xxx. ERASE will only delete files.

One can use RmDir() to remove a directory in TP.

Deltree would be something like:

var fp:file;

Procedure Deltree(s:string);
var sr:searchrec;
Begin
  {$i-}
  findFirst(s+'\*.*',anyfile,sr);
  while doserror=0 do begin
    if sr.attr and directory>0 then Deltree(s+'\'+sr.name+)
       else begin
              assign(fp,s+'\'+sr.name);
              setfattr(fp,0)
              erase(fp);
              inoutres:=0;
            End;
    findnext(sr);
  End;
  rmdir(s);
  inoutres:=0;
  {Si+}
End;

That is just a sketch. The code is EXTREMELY DANGEROUS so use at your own
risk.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 Delete

Quote:
>One can use RmDir() to remove a directory in TP.

>Deltree would be something like:

>var fp:file;

>Procedure Deltree(s:string);
>var sr:searchrec;
>Begin
>  {$i-}
>  findFirst(s+'\*.*',anyfile,sr);
>  while doserror=0 do begin
>    if sr.attr and directory>0 then Deltree(s+'\'+sr.name+)
>       else begin
>              assign(fp,s+'\'+sr.name);
>              setfattr(fp,0)
>              erase(fp);
>              inoutres:=0;
>            End;
>    findnext(sr);
>  End;
>  rmdir(s);
>  inoutres:=0;
>  {Si+}
>End;

>That is just a sketch. The code is EXTREMELY DANGEROUS so use at your own
>risk.

>Osmo

Osmo,

Thanks for the tip - this was new to me.

Klaus



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. deleting ok unless the first one to be deleted

2. DBASE: permanently deleting deleted records

3. I'm stuck and need advise - cannot fix Record/Key Deleted

4. data aware grid and table - record/key deleted

5. how to delete a database in SQL editor

6. I CAN'T DELETE A TABLE

7. How to delete record without prompt message?

8. Add and delete items from arrays

9. Session.FindDatabase finding deleted alias

10. IB won't delete my table!

11. Combined Key Press (VK-CONTROL+VK-DELETE) - How To Capture

12. Deleting A Record

 

 
Powered by phpBB® Forum Software