Solved

deleting files

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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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