Delete files in a directory in c++

I need to delete all files with extension ".txt" form a specific folder in C++.
How do I do this?

I do not wnat to use system("del *.txt");

Thanks
Regards
Jas
jas123Asked:
Who is Participating?
 
George TokasConnect With a Mentor Commented:
Assuming that you are using BCB...
Check out online help for FindFirst(..) .
It is under file management utilities.
With FindFirst you can locate the first occurence of a file matching the criteria you want (*.txt) in your case...
From the structure TSerchRec you can get the ansistring contains the filename.
After you obtain with those the filename in an AnsiString you can use:
DeleteFile(AnsiString Filename) to delete.


gtokas.
0
 
CayceCommented:
Is this question abandoned? Wasn't gotkas comment sufficient? do you need an example? is it kerry or is it bush?

Please let us know jas.

Regards
0
All Courses

From novice to tech pro — start learning today.