Thread View: borland.public.cppbuilder.nativeapi
9 messages
9 total messages
Started by Jos�
Mon, 07 Jan 2008 13:18
Cannot delete a directory
Author: Jos�
Date: Mon, 07 Jan 2008 13:18
Date: Mon, 07 Jan 2008 13:18
12 lines
1206 bytes
1206 bytes
My program uses findfirst() and rename() to remove all files from a folder. And then it executes RemoveDir() and this fails. When I try to remove the empty folder with the Windows Explorer, this fails. When I close my C++ program, I can remove the folder with the Explorer. It appears that my program locks the folder. Is there a remedy? -- Jos�
Re: Cannot delete a directory
Author: Bob Gonder
Date: Mon, 07 Jan 2008 14:25
Date: Mon, 07 Jan 2008 14:25
7 lines
1241 bytes
1241 bytes
Jos� wrote: >My program uses findfirst() and rename() to remove all files from a >folder. And then it executes RemoveDir() and this fails. I'm guessing you still have the "find" open. findclose() might help
Re: Cannot delete a directory
Author: Ed Mulroy [TeamB]
Date: Mon, 07 Jan 2008 14:29
Date: Mon, 07 Jan 2008 14:29
30 lines
2025 bytes
2025 bytes
I don't know how rename can delete a file. DeleteFile, remove and unlink all can do that and are provided. Try using one of them. If the directory in question is selected as the current directory then it is active and Windows will block its deletion. You can find the current directory setting with GetCurrentDirectory and alter it with SetCurrentDirectory. All of DeleteFile, GetCurrentDirectory and SetCurrentDirectory are Win32 API functions. > My program uses findfirst ... Don't forget to use findclose after finishing with findfirst and findnext. . Ed > Jos� wrote in message > news:ne94o39s71g92csaaup85ufdomjisjvu4h@4ax.com... > > My program uses findfirst() and rename() to remove all files from > a folder. And then it executes RemoveDir() and this fails. > > When I try to remove the empty folder with the Windows Explorer, > this fails. > > When I close my C++ program, I can remove the folder with the > Explorer. > > It appears that my program locks the folder. Is there a remedy?
Re: Cannot delete a directory
Author: Bob Gonder
Date: Mon, 07 Jan 2008 15:06
Date: Mon, 07 Jan 2008 15:06
5 lines
1183 bytes
1183 bytes
Ed Mulroy [TeamB] wrote: >I don't know how rename can delete a file. By giving it a new path.
Re: Cannot delete a directory
Author: Jos�
Date: Mon, 07 Jan 2008 15:36
Date: Mon, 07 Jan 2008 15:36
15 lines
1479 bytes
1479 bytes
On Mon, 07 Jan 2008 06:25:17 -0800, Bob Gonder <notbg@notmindspring.invalid> wrote in borland.public.cppbuilder.nativeapi: >>My program uses findfirst() and rename() to remove all files from a >>folder. And then it executes RemoveDir() and this fails. > >I'm guessing you still have the "find" open. >findclose() might help That worked! I never knew about the existence of findclose(). The help file has an example without it, so how was I to know that findclose() existed? -- Jos�
Re: Cannot delete a directory
Author: Jos�
Date: Mon, 07 Jan 2008 15:38
Date: Mon, 07 Jan 2008 15:38
18 lines
1482 bytes
1482 bytes
On Mon, 7 Jan 2008 09:29:12 -0500, "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in borland.public.cppbuilder.nativeapi: >I don't know how rename can delete a file. DeleteFile, remove and unlink >all can do that and are provided. Try using one of them. Rename() doesn't delete a file, but it moves the file to another directory, so that the source directory becomes empty. I do not follow your suggestion to use DeleteFile(), since that's not what I want. >> My program uses findfirst ... > >Don't forget to use findclose after finishing with findfirst and findnext. Yes, that worked. It's not in the help file. -- Jos�
Re: Cannot delete a directory
Author: Ed Mulroy [TeamB]
Date: Mon, 07 Jan 2008 16:16
Date: Mon, 07 Jan 2008 16:16
11 lines
1357 bytes
1357 bytes
That moves the file to a new directory on the same drive. It does not delete the file. . Ed > Bob Gonder wrote in message > news:5vf4o39uusmrsh6ao8enmr5g6ocku1ln1j@4ax.com... > >>I don't know how rename can delete a file. > > By giving it a new path.
Re: Cannot delete a directory
Author: Jos�
Date: Mon, 07 Jan 2008 16:52
Date: Mon, 07 Jan 2008 16:52
10 lines
1329 bytes
1329 bytes
On Mon, 7 Jan 2008 11:16:25 -0500, "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in borland.public.cppbuilder.nativeapi: >That moves the file to a new directory on the same drive. It does not >delete the file. I never said that I wanted to delete any file. -- Jos�
Re: Cannot delete a directory
Author: Thomas Maeder [TeamB]
Date: Mon, 07 Jan 2008 17:34
Date: Mon, 07 Jan 2008 17:34
10 lines
1500 bytes
1500 bytes
Jos� <jose@127.0.0.1> writes: >> >>I'm guessing you still have the "find" open. findclose() might help > > That worked! I never knew about the existence of findclose(). The > help file has an example without it, so how was I to know that > findclose() existed? Please file a bug report.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads