Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Delete Folders

Status
Not open for further replies.

rowanco

Programmer
Jul 17, 2001
9
AU
I have some code that creates some dirs using CreateDirectory(), which are temporary and need to be removed later.

Initially I wrote the code on Win98 using RemoveDirectory() and there was no problem, I have since tried to execute the code on Win2000 and now the directories won't be removed. The interesting thing is, sometimes it would work and a dir would be removed, but mostly it won't remove them at all.

I have tried a system call with the DOS command 'rmdir' as well, but same problem. I realise it may be the permissions on 2000, but I jsut use CreateDirectory with NULL set for the security attributes paramater, so I assume the directories created are removeable as normal, as I can delete manually from explorer.

If anyone has experienced a similar problem or can offer some help it is greatly appreciated.
 
Try puting your code in an OnTimer event handler, set the timer at 2000 that is 2 sec. I have had the same problem and the timer fixed it. Probly your program is closing to fast and cannot remove the folders you ask it to.
 
Hi, thanks for your reply, this is a really strange behaviour.

When you say On Timer, do you mean call:

SetTimer(hwnd, idTimer, 2000, (TIMERPROC) NULL);

and then catch it in the main Switch for case WM_TIMER,

If so where would you put the call to: SetTimer()?

Just before the 'on exit' code in the WM_CLOSE case?
 
Drop a timer on your form then:
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
Then:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1->Enabled = false;
Put some of the RemoveDirectory() here, or try all of them here.
Close();
}
//---------------------------------------------------------------------------
if need be use 2 timers;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top