Click here to Skip to main content
15,898,020 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:37
George_George30-Jul-07 2:37 
AnswerRe: can not delete a file Pin
Dominik Reichl30-Jul-07 0:48
Dominik Reichl30-Jul-07 0:48 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 0:53
George_George30-Jul-07 0:53 
GeneralRe: can not delete a file 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 2:38
George_George30-Jul-07 2:38 
AnswerRe: can not delete a file Pin
SandipG 30-Jul-07 1:14
SandipG 30-Jul-07 1:14 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:39
George_George30-Jul-07 2:39 
AnswerRe: can not delete a file Pin
Don Box30-Jul-07 2:17
Don Box30-Jul-07 2:17 
Hello George_George, I'll tell u the exact problem u r having and how to rectify it.

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


----------------------------------------------------------
The problem lies in the highlighted lines. FindFileData.cFileName contains only the FILE NAME, NOT PATH. So the problem. Rectify it by replacing the highlighted lines by DeleteFile(path);


Come online at:-
jubinc@skype

GeneralRe: can not delete a file Pin
Jonathan [Darka]30-Jul-07 2:29
professionalJonathan [Darka]30-Jul-07 2:29 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:41
George_George30-Jul-07 2:41 
GeneralRe: can not delete a file Pin
Jonathan [Darka]30-Jul-07 2:52
professionalJonathan [Darka]30-Jul-07 2:52 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:40
George_George30-Jul-07 2:40 
AnswerRe: can not delete a file Pin
Bryster30-Jul-07 2:19
Bryster30-Jul-07 2:19 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:44
George_George30-Jul-07 2:44 
AnswerRe: can not delete a file Pin
gvisgr830-Jul-07 2:19
gvisgr830-Jul-07 2:19 
QuestionRe: can not delete a file Pin
David Crow30-Jul-07 3:32
David Crow30-Jul-07 3:32 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 2:44
George_George30-Jul-07 2:44 
AnswerRe: can not delete a file Pin
George_George30-Jul-07 4:11
George_George30-Jul-07 4:11 
GeneralRe: can not delete a file Pin
David Crow30-Jul-07 3:49
David Crow30-Jul-07 3:49 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 4:12
George_George30-Jul-07 4:12 
GeneralRe: can not delete a file Pin
David Crow30-Jul-07 4:46
David Crow30-Jul-07 4:46 
GeneralRe: can not delete a file Pin
George_George30-Jul-07 16:46
George_George30-Jul-07 16:46 
Questiongetline() Pin
garfaoui30-Jul-07 0:09
garfaoui30-Jul-07 0:09 
AnswerRe: getline() Pin
Nelek30-Jul-07 0:22
protectorNelek30-Jul-07 0:22 
GeneralRe: getline() Pin
garfaoui30-Jul-07 0:25
garfaoui30-Jul-07 0:25 

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.