Solved

deleting files

Posted on 1998-10-22
4
221 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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