Author | Topic: DirRemove() | |
---|---|---|
Carlos A Beling | DirRemove() on Tue, 20 Aug 2019 11:11:36 -0300 Good day. DirRemove() is returning error -145 and I can not see what it means. It has not mention at it in XbtSys.ch and executing DosErrorMessage(-145) it returns "". Do one know where I can find what that error means? Fraternally Beling | |
Tim Callahan | Re: DirRemove() on Tue, 20 Aug 2019 09:39:19 -0700 On Tue, 20 Aug 2019 11:11:36 -0300, Carlos A Beling <beling@bipbip.com.br> wrote: Hi - This shows DOS error messages. Not sure if the 145 is a DOS error. Tim https://vivaclipper.wordpress.com/2013/10/24/extended-dos-error-messages/ >Good day. >DirRemove() is returning error -145 and I can not see what it means. >It has not mention at it in XbtSys.ch and executing >DosErrorMessage(-145) it returns "". >Do one know where I can find what that error means? > >Fraternally >Beling > > | |
Carlos A Beling | Re: DirRemove() on Tue, 20 Aug 2019 15:19:33 -0300 Hi Tim. DosErrorMessage() returns empty string. Fraternlly Beling Em 20/08/2019 13:39, Tim Callahan escreveu: > On Tue, 20 Aug 2019 11:11:36 -0300, Carlos A Beling > <beling@bipbip.com.br> wrote: > > Hi - > This shows DOS error messages. Not sure if the 145 is a DOS error. > Tim > > https://vivaclipper.wordpress.com/2013/10/24/extended-dos-error-messages/ > >> Good day. >> DirRemove() is returning error -145 and I can not see what it means. >> It has not mention at it in XbtSys.ch and executing >> DosErrorMessage(-145) it returns "". >> Do one know where I can find what that error means? >> >> Fraternally >> Beling >> >> | |
Jim Lee | Re: DirRemove() on Tue, 20 Aug 2019 20:32:19 +0200 hi, > DirRemove() is returning error -145 and I can not see what it means. > It has not mention at it in XbtSys.ch and executing DosErrorMessage(-145) > it returns "". > Do one know where I can find what that error means? 145 ERROR_DIR_NOT_EMPTY The directory is not empty. --- Diese E-Mail wurde von AVG auf Viren geprüft. http://www.avg.com | |
Carlos A Beling | Re: DirRemove() on Tue, 20 Aug 2019 16:44:15 -0300 Hi Jim. Good day. The return value of the function is -145 (negative). Fraternally Beling Em 20/08/2019 15:32, Jim Lee escreveu: > hi, > >> DirRemove() is returning error -145 and I can not see what it means. >> It has not mention at it in XbtSys.ch and executing DosErrorMessage(-145) >> it returns "". >> Do one know where I can find what that error means? > > 145 ERROR_DIR_NOT_EMPTY The directory is not > empty. > > > > --- > Diese E-Mail wurde von AVG auf Viren geprüft. > http://www.avg.com > | |
Andreas Gehrs-Pahl | Re: DirRemove() on Wed, 21 Aug 2019 07:46:36 -0400 Carlos, >The return value of the function is -145 (negative). The XbTools function DirRemove() always returns OS Errors as negative values. You can see that clearly, if you look in the XbTSys.ch include file. Just use DosErrorMessage(abs(nReturn)) to get the correct error message. But I recommend that you use the standard Xbase++ RemoveDir() function instead. If that function returns FALSE, you can use the FError() function to retrieve the corresponding OS Error Code. That way, you don't need to add the XbTools DLLs to your project. Also keep in mind that many XbTools functions aren't thread-safe. Hope that helps, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Carlos A Beling | Re: DirRemove() on Wed, 21 Aug 2019 16:20:43 -0300 Hi Andreas: good day. Many thanks. I changed my code for using RemoveDir(). Fraternally Beling Em 21/08/2019 08:46, Andreas Gehrs-Pahl escreveu: > Carlos, > >> The return value of the function is -145 (negative). > > The XbTools function DirRemove() always returns OS Errors as negative > values. You can see that clearly, if you look in the XbTSys.ch include file. > > Just use DosErrorMessage(abs(nReturn)) to get the correct error message. > > But I recommend that you use the standard Xbase++ RemoveDir() function > instead. If that function returns FALSE, you can use the FError() function > to retrieve the corresponding OS Error Code. > > That way, you don't need to add the XbTools DLLs to your project. Also keep > in mind that many XbTools functions aren't thread-safe. > > Hope that helps, > > Andreas > | |
Carlos A Beling | Re: DirRemove() on Fri, 23 Aug 2019 17:23:19 -0300 Hello Andreas. Good afternoon. I am trying to remove the attached folder for testing purpose and the function RemoveDir() seems do not work according to its documentation. May be you want seeing what is happening and can correct my fault. For you to do this please: 1) unpack the attached Test.zip 2) compile the program RemoveMe.prg using xpp RemoveMe /link 3) execute RemoveMe.exe. This example was coded for to execute in Drive C: Executing the test in My computer only the file ..\RemoveMe\RemoveMeToo\RemovemeHI.txt (hidden) is removed. Fraternally Beling Em 21/08/2019 08:46, Andreas Gehrs-Pahl escreveu: > Carlos, > >> The return value of the function is -145 (negative). > > The XbTools function DirRemove() always returns OS Errors as negative > values. You can see that clearly, if you look in the XbTSys.ch include file. > > Just use DosErrorMessage(abs(nReturn)) to get the correct error message. > > But I recommend that you use the standard Xbase++ RemoveDir() function > instead. If that function returns FALSE, you can use the FError() function > to retrieve the corresponding OS Error Code. > > That way, you don't need to add the XbTools DLLs to your project. Also keep > in mind that many XbTools functions aren't thread-safe. > > Hope that helps, > > Andreas > Test.zip | |
Jim Lee | Re: DirRemove() on Fri, 23 Aug 2019 23:35:39 +0200 hi, you can't remove a Directory if it is not empty includes Subdir.with RemoveDir() / DirRemove() while it work with Explorer you can try to use SHfile API CLASS TShFileOperation from Pablo --- Diese E-Mail wurde von AVG auf Viren geprüft. http://www.avg.com | |
Andreas Gehrs-Pahl | Re: DirRemove() on Sat, 24 Aug 2019 03:58:39 -0400 Jimmy, >you can't remove a Directory if it is not empty includes Subdir.with >RemoveDir() / DirRemove() Since Version 2.00.906, you can indeed delete a directory and all its contents -- as long as you have the rights to do it -- using the new <lForce> parameter of the RemoveDir() function. The (obsolete) XbTools function DirRemove() doesn't have that feature, though. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Carlos A Beling | Re: DirRemove() on Sat, 24 Aug 2019 12:13:23 -0300 Hello Jim: good day. Many thanks. Unfortunately TShFileOperation requires a window and I do not want to show dialogs. Fraternally Beling Em 23/08/2019 18:35, Jim Lee escreveu: > hi, > > you can't remove a Directory if it is not empty includes Subdir.with > RemoveDir() / DirRemove() > > while it work with Explorer you can try to use SHfile API > CLASS TShFileOperation > from Pablo > > > > > --- > Diese E-Mail wurde von AVG auf Viren geprüft. > http://www.avg.com > | |
Andreas Gehrs-Pahl | Re: DirRemove() on Sat, 24 Aug 2019 03:51:25 -0400 Carlos, >I am trying to remove the attached folder for testing purpose and the >function RemoveDir() seems do not work according to its documentation. There is nothing wrong with the function or its documentation, even though it could be a little bit more precise about failure modes. >Executing the test in My computer only the file >..\RemoveMe\RemoveMeToo\RemovemeHI.txt (hidden) is removed. If you don't have access to a file (or directory) inside the directory that you want to remove -- either because the file is Read-Only, requires special access (because it is owned by a different user), or it is currently opened by a different process -- then RemoveDir() can't delete it, even with the <lForce> parameter set to true. You will have to get the right credentials (for your Xbase++ process) and remove the Read-Only flag from any files and directories, before you can delete them. Basically, if FErase() would fail, RemoveDir() will also fail. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Carlos A Beling | Re: DirRemove() on Sat, 24 Aug 2019 12:11:10 -0300 Hello Andreas: Good day. Many thanks again. The folder that need to be removed may to be created for an old one process or by the current processes. Both may to have files Read Only or Hidden. Then is best to remove the file attributes before to erase the directory? Another question is, if it is possible, how to know if a folder or a file is been accessed by other processes? Fraternally Beling Em 24/08/2019 04:51, Andreas Gehrs-Pahl escreveu: > Carlos, > >> I am trying to remove the attached folder for testing purpose and the >> function RemoveDir() seems do not work according to its documentation. > > There is nothing wrong with the function or its documentation, even though > it could be a little bit more precise about failure modes. > >> Executing the test in My computer only the file >> ..\RemoveMe\RemoveMeToo\RemovemeHI.txt (hidden) is removed. > > If you don't have access to a file (or directory) inside the directory that > you want to remove -- either because the file is Read-Only, requires special > access (because it is owned by a different user), or it is currently opened > by a different process -- then RemoveDir() can't delete it, even with the > <lForce> parameter set to true. > > You will have to get the right credentials (for your Xbase++ process) and > remove the Read-Only flag from any files and directories, before you can > delete them. > > Basically, if FErase() would fail, RemoveDir() will also fail. > > Andreas > | |
Andreas Gehrs-Pahl | Re: DirRemove() on Sat, 24 Aug 2019 14:28:38 -0400 Carlos, >Then is best to remove the file attributes before to erase the directory? Yes, if you have the access rights, remove all the read-only attributes. >Another question is, if it is possible, how to know if a folder or a >file is been accessed by other processes? Try to delete the file and if you get an OS Error 32, then some process has the file open at the time. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Carlos A Beling | Re: DirRemove() on Mon, 26 Aug 2019 11:13:52 -0300 Hello Andreas. Good day. Many thanks again. I think the best way for deleting a folder is first to parse all the files in the directory tree for to see if it has any files in use and, after this, to change the files attributes and delete the folder. Fraternally Beling Em 24/08/2019 15:28, Andreas Gehrs-Pahl escreveu: > Carlos, > >> Then is best to remove the file attributes before to erase the directory? > > Yes, if you have the access rights, remove all the read-only attributes. > >> Another question is, if it is possible, how to know if a folder or a >> file is been accessed by other processes? > > Try to delete the file and if you get an OS Error 32, then some process has > the file open at the time. > > Andreas > |