Hi,
i'm having trouble using _rmdir() It keeps giving an error code 13 (Permission denied) even though i've used _mkdir() to create the directory earlier in the program.
(I'm using Visual C++ v6.0)
If anyone has any ideas any help would be appreciated.
Cheers,
Dave H.
Hi,
still trying to get this directory deleted. It must be something i'm doing once i've created the directory, although i dont know what!
Heres a bit of code showing the the bare bones.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{
CreateDirectory("testdir",NULL);
FILE *temp_file;
temp_file = fopen("testdir\\testfile.txt","w");
for ( int i = 0 ; i < 15 ; ++i)
fprintf(temp_file,"Line Number %i\n",i);
fclose(temp_file);
CFileFind Clear;
BOOL bDelete = Clear.FindFile("testdir\\*");
while (bDelete)
{
bDelete = Clear.FindNextFile();
DeleteFile(Clear.GetFilePath() );
}
RemoveDirectory("testdir");
}
if i comment out the stuff between the CreateDirectory() and RemoveDirectory() the directory gets deleted. Has anyone got any ideas what i'm doing wrong?
Thanks in advance.
Dave H
I'm not familiar with CFileFind. Have you tried the native WIN32 calls FindFirstFile/FindNextFile/FindClose? After all, you're using native calls to create and delete the directory.
CFileFind must have opened a handle to testdir when you opened the directory for searching.
you haven't closed it and are trying to remove the directory.. this might be the problem.