Click here to Skip to main content
15,922,533 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: post thread message() Pin
Iain Clarke, Warrior Programmer30-Jul-07 4:20
Iain Clarke, Warrior Programmer30-Jul-07 4:20 
GeneralRe: post thread message() Pin
shakumar_2230-Jul-07 4:38
shakumar_2230-Jul-07 4:38 
GeneralRe: post thread message() Pin
Iain Clarke, Warrior Programmer30-Jul-07 5:06
Iain Clarke, Warrior Programmer30-Jul-07 5:06 
QuestionHow to put an MFC Dialog box project into another existing project Pin
vladimir7230-Jul-07 2:29
vladimir7230-Jul-07 2:29 
AnswerRe: How to put an MFC Dialog box project into another existing project Pin
Nelek30-Jul-07 2:40
protectorNelek30-Jul-07 2:40 
GeneralRe: How to put an MFC Dialog box project into another existing project Pin
vladimir7230-Jul-07 2:51
vladimir7230-Jul-07 2:51 
GeneralRe: How to put an MFC Dialog box project into another existing project Pin
Hans Dietrich30-Jul-07 3:12
mentorHans Dietrich30-Jul-07 3:12 
AnswerRe: How to put an MFC Dialog box project into another existing project Pin
vladimir7230-Jul-07 3:58
vladimir7230-Jul-07 3:58 
GeneralRe: How to put an MFC Dialog box project into another existing project Pin
Nelek30-Jul-07 20:23
protectorNelek30-Jul-07 20:23 
Questionre: Fast Searching... Pin
Bryster30-Jul-07 1:54
Bryster30-Jul-07 1:54 
AnswerRe: re: Fast Searching... Pin
Randor 30-Jul-07 1:58
professional Randor 30-Jul-07 1:58 
GeneralRe: re: Fast Searching... Pin
Bryster30-Jul-07 2:25
Bryster30-Jul-07 2:25 
AnswerRe: re: Fast Searching... Pin
Hans Dietrich30-Jul-07 3:17
mentorHans Dietrich30-Jul-07 3:17 
GeneralRe: re: Fast Searching... Pin
Bryster30-Jul-07 4:12
Bryster30-Jul-07 4:12 
Questionre: Problems with Progress Bar Pin
Bryster30-Jul-07 1:25
Bryster30-Jul-07 1:25 
AnswerRe: re: Problems with Progress Bar Pin
Hans Dietrich30-Jul-07 3:21
mentorHans Dietrich30-Jul-07 3:21 
GeneralRe: re: Problems with Progress Bar Pin
Bryster30-Jul-07 4:24
Bryster30-Jul-07 4:24 
AnswerRe: re: Problems with Progress Bar Pin
krmed30-Jul-07 4:53
krmed30-Jul-07 4:53 
QuestionRe: re: Problems with Progress Bar Pin
Mark Salsbery30-Jul-07 6:20
Mark Salsbery30-Jul-07 6:20 
Questioncan not delete a file Pin
George_George30-Jul-07 0:13
George_George30-Jul-07 0:13 
AnswerRe: can not delete a file Pin
Jonathan [Darka]30-Jul-07 0:18
professionalJonathan [Darka]30-Jul-07 0:18 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 0:23
George_George30-Jul-07 0:23 
GeneralRe: can not delete a file [modified] Pin
Jonathan [Darka]30-Jul-07 0:57
professionalJonathan [Darka]30-Jul-07 0:57 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 1:23
George_George30-Jul-07 1:23 
Thanks Jonathan,


I have tried and slightly modified your program to make it compile. Smile | :)

Now the error condition is, error number 2 -- system can not find specified file. I am confused since the file actually exists.

I need to using absolute path other than relative path to delete the file?

<br />
int remove_non_empty_directory(const char* path)<br />
{<br />
    WIN32_FIND_DATA FindFileData;<br />
    int rtn;<br />
    HANDLE hFind = FindFirstFile(path, &FindFileData);<br />
    int bDelete = 0;<br />
<br />
    if (hFind == INVALID_HANDLE_VALUE)<br />
    {		<br />
        FindClose(hFind);<br />
        return -1;<br />
    }<br />
    else<br />
    {<br />
        if((_tcscmp((LPCSTR)FindFileData.cFileName, "..") == 0) || (_tcscmp((LPCSTR)FindFileData.cFileName, ".") == 0))<br />
        {<br />
            bDelete = 0;<br />
        }<br />
        if(bDelete) // delete 1st file<br />
        {<br />
            rtn = DeleteFile((LPCSTR)FindFileData.cFileName); // .... original error handling code<br />
        }<br />
        // List all the other files in the directory and delete all file<br />
        while (FindNextFile(hFind, &FindFileData) != 0)<br />
        {<br />
             bDelete = 1;<br />
             if((_tcscmp((LPCSTR)FindFileData.cFileName, "..") == 0) || (_tcscmp((LPCSTR)FindFileData.cFileName, ".") == 0))<br />
             {<br />
                 bDelete = 0;<br />
             }<br />
             if(bDelete)<br />
             {<br />
                 rtn = DeleteFile((LPCSTR)FindFileData.cFileName);<br />
                 if (0 == rtn)<br />
                 {<br />
                        ErrorExit (NULL);<br />
                 }<br />
             }<br />
        }<br />
        FindClose(hFind);<br />
    }<br />
<br />
    return 0;<br />
}<br />



regards,
George
GeneralRe: can not delete a file Pin
Jonathan [Darka]30-Jul-07 2:06
professionalJonathan [Darka]30-Jul-07 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.