Solved

Delete files in a directory in c++

Posted on 2004-10-24
584 Views
Last Modified: 2013-11-17
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
0
Question by:jas123
    2 Comments
     
    LVL 16

    Accepted Solution

    by:
    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
     
    LVL 9

    Expert Comment

    by:Cayce
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    How to create project in Eclipse ? 1 167
    eclipse error 7 76
    eclipse ide not starting 16 71
    Java Help 2 54
    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    856 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now