Solved

deleting files

Posted on 1998-10-22
4
215 Views
Last Modified: 2013-11-20
hi,

I'm using NT 4.0, VC++ 5.0.

I want to write a function that deletes all the files "tmp*" from one of the libraries when I close my program.
(These were temporary files and I don't want them anymore)
How do I do it?
0
Comment
Question by:hilit
4 Comments
 
LVL 1

Expert Comment

by:Bridge
ID: 1323708
Use CFileFind to cycle through the files and DeleteFile to remove them.
0
 
LVL 2

Accepted Solution

by:
jstolan earned 50 total points
ID: 1323709
Pass in the wildcard search you wist to perform into the CFileFind class, then pass in the resulting file names into the DeleteFile function.  It will be sort of like this:

CFileFind finder;
BOOL bFound = finder.FindFile("c:\library\tmp*.*");
if( bFound )
{
    while( finder.FindNextFile() )
    {
        CString cszPath = finder.GetFilePAth();
        DeleteFile( cszPath );
    }
}
0
 
LVL 1

Author Comment

by:hilit
ID: 1323710
thanks,
one little thing - it should be "c:\\library\\tmp*.*" and not with 1 slash only.
0
 

Expert Comment

by:cliffspielman
ID: 1323711
How can this code be adjusted so that the deleted files are first copied to the Recycle Bin?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 51
Doc'in system (example?) BA 7 112
centeredAverage challenge 8 167
Making an alias 7 95
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question