How to delete a folder?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cosmos22
    New Member
    • Feb 2008
    • 9

    How to delete a folder?

    Hello, I have recently been able to delete files using this code(With the aid of others from the forum) And I was wondering how you can change this, to suit deleting a folder

    #include <iostream>
    #include <windows.h>
    int main(int argc, const char * argv[])
    {


    // Get a pointer to the file name/path
    const char * pFileToDelete = "c:\\Progra m Files\\myfile.t xt";

    // try deleting it using DeleteFile
    if(DeleteFile(p FileToDelete ))

    {
    // succeeded
    std::cout << "Deleted file" << std::endl;
    }
    else
    {
    // failed
    std::cout << "Failed to delete the file" << std::endl;
    }
    std::cin.get();
    return 0;
    }

    Thank you
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I did a Google on "deleting a folder" and "Windows" and got 108,000 hits.

    Maybe you could read some of these pages.

    Comment

    Working...