How to delete all files in a folder from within app 
Author Message
 How to delete all files in a folder from within app

In a C5b legacy app I need to be able to delete a number of temporary files
in a particular folder when the app starts up.  I tried embedding the code
run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
2000 machine).  Is there a way of achieving this?  I do need to be able to
use wildcards as I do not know what files might be there.

Thanks

Ian Burgess



Sun, 06 Feb 2005 16:47:10 GMT  
 How to delete all files in a folder from within app
Try

run('del c:\temp\sregtmp\*.* /Q')

-Niilo-


Quote:
> In a C5b legacy app I need to be able to delete a number of temporary
files
> in a particular folder when the app starts up.  I tried embedding the code
> run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
> 2000 machine).  Is there a way of achieving this?  I do need to be able to
> use wildcards as I do not know what files might be there.

> Thanks

> Ian Burgess



Sun, 06 Feb 2005 18:31:26 GMT  
 How to delete all files in a folder from within app
Take a look at the Directory() function.
You can use it to get a list of all the files in a particular directory and
load them into a queue.
You can then spin through the queue with a loop and examine the files that are
there.
if you don't want the file, just use the REMOVE() statement to get ride of
them.

        Tim

Quote:

> In a C5b legacy app I need to be able to delete a number of temporary files
> in a particular folder when the app starts up.  I tried embedding the code
> run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
> 2000 machine).  Is there a way of achieving this?  I do need to be able to
> use wildcards as I do not know what files might be there.

> Thanks

> Ian Burgess



Sun, 06 Feb 2005 18:34:01 GMT  
 How to delete all files in a folder from within app
This is the Pure Clarion way - using a queue.  In this example, LOCFolder is
a Queue:

DIRECTORY(LOC:Folder,LONGPATH() & '\VH\*.*',0)  !VH is name of subfolder
LOC:Recs=RECORDS(LOC:Folder)
LOOP i = LOC:Recs TO 1 BY -1
    GET(LOC:Folder,i)
    REMOVE(LONGPATH() & '\VH\' & Name)
END


Quote:
> In a C5b legacy app I need to be able to delete a number of temporary
files
> in a particular folder when the app starts up.  I tried embedding the code
> run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
> 2000 machine).  Is there a way of achieving this?  I do need to be able to
> use wildcards as I do not know what files might be there.

> Thanks

> Ian Burgess



Sun, 06 Feb 2005 21:11:13 GMT  
 How to delete all files in a folder from within app
Thanks for all your suggestions.

I have opted for the directory/queue method and it works fine.  I think this
is a better option than shelling to a DOS command.

Ian Burgess


Quote:
> This is the Pure Clarion way - using a queue.  In this example, LOCFolder
is
> a Queue:

> DIRECTORY(LOC:Folder,LONGPATH() & '\VH\*.*',0)  !VH is name of subfolder
> LOC:Recs=RECORDS(LOC:Folder)
> LOOP i = LOC:Recs TO 1 BY -1
>     GET(LOC:Folder,i)
>     REMOVE(LONGPATH() & '\VH\' & Name)
> END



> > In a C5b legacy app I need to be able to delete a number of temporary
> files
> > in a particular folder when the app starts up.  I tried embedding the
code
> > run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
> > 2000 machine).  Is there a way of achieving this?  I do need to be able
to
> > use wildcards as I do not know what files might be there.

> > Thanks

> > Ian Burgess



Sun, 06 Feb 2005 21:44:37 GMT  
 How to delete all files in a folder from within app
I can't remember exactly why, but I didn't use that method, instead I used
similar API stuff.
     MODULE('Windows')
      FindFirstFile(*cstring GLO:szFileName, *WIN32_FIND_DATA
GLO:FindFileData),long,Pascal,raw,name('FindFirstFileA')
      FindNextFile(long GLO:hFindFile, *WIN32_FIND_DATA
GLO:FindFileData),byte,pascal,raw,name('FindNextFileA')
      DeleteFile(*cstring
GLO:dfilename),byte,raw,pascal,proc,NAME('deletefileA')
     END


Quote:
> This is the Pure Clarion way - using a queue.  In this example, LOCFolder
is
> a Queue:

> DIRECTORY(LOC:Folder,LONGPATH() & '\VH\*.*',0)  !VH is name of subfolder
> LOC:Recs=RECORDS(LOC:Folder)
> LOOP i = LOC:Recs TO 1 BY -1
>     GET(LOC:Folder,i)
>     REMOVE(LONGPATH() & '\VH\' & Name)
> END



> > In a C5b legacy app I need to be able to delete a number of temporary
> files
> > in a particular folder when the app starts up.  I tried embedding the
code
> > run('del c:\temp\sregtmp\*.*') but it seemed to have no effect (on a WIN
> > 2000 machine).  Is there a way of achieving this?  I do need to be able
to
> > use wildcards as I do not know what files might be there.

> > Thanks

> > Ian Burgess



Mon, 07 Feb 2005 00:08:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Deleting a file from within Clarion App

2. How to list files, folders and all their files under the folders

3. f.saveasjpeg() deletes file in compiled app

4. Deleted .app File.. Need help desperately

5. delete temp files in CPD2110 app

6. How to delete folders?

7. deleting a Folder

8. Creating/deleting folders and shortcuts.

9. Creating & Deleting Folders

10. How do you create a folder within Clarion 4

11. Can't delete folder

 

 
Powered by phpBB® Forum Software