Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

deleting files

Posted on 1998-10-22
4
Medium Priority
?
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

660 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