How to delete the Folder and its file using VC++ code

Discussion in 'C++' started by nirub, Jan 5, 2006.

  1. nirub

    nirub Guest

    hi
    this nirub i want the guideness for deleting the folder and its
    files...
    here i attached my code deleting file but i cant delete the folder..
    if any of one give me idea for that.....

    WIN32_FIND_DATA FindFileData;
    HANDLE hHandle;
    int complt;
    char FileName[100];
    strcpy(FileName,"");
    char rpath[]="C:\\Sam";
    char Path[]="C:\\Sam\\";
    SetCurrentDirectory(Path);
    hHandle=FindFirstFile("*.*",&FindFileData);

    if(hHandle == INVALID_HANDLE_VALUE)
    MessageBox("Path NotFound");
    else
    {
    while(complt)
    {
    strcpy(FileName,Path);
    strcat(FileName,FindFileData.cFileName);
    DeleteFile(FileName);
    complt=FindNextFile(hHandle,&FindFileData);
    }
    }
    FindClose(hHandle);
    int d=RemoveDirectory(rpath);
    if(d)
    MessageBox("Deleted");
    else
    MessageBox("Sorry i cant");
    int i=CreateDirectory(rpath,NULL);
    if(i)
    MessageBox("Created");
    else
    MessageBox("Sorry i cant");
     
    nirub, Jan 5, 2006
    #1
    1. Advertisements

  2. Wrong newsgroup. Try 'microsoft.public.*' hierarchy.

    V
     
    Victor Bazarov, Jan 5, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.