Archer Posted November 24, 2008 Share Posted November 24, 2008 (edited) Hi, all That's a little weird. If I use the following code to test the DirRemove() function, the failure would be shown in the log. However, I did not open this folder or something and I do have the admin permission. Why? One more thing to mention is that although the error code is 0 but the folder is gone..... Why this? If it could be delete the folder totally, it should be successful with returning code 1. ------------------- #include <File.au3> $csLogFileFullPath = "test.log" $sFileName = "C:\Test1" DirCreate($sFileName) If FileExists($sFileName) Then _FileWriteLog($csLogFileFullPath, $sFileName & " exists.") EndIf DirRemove($sFileName, 0) If @error = 0 Then _FileWriteLog($csLogFileFullPath, "Failed to delete folder " & $sFileName) Else _FileWriteLog($csLogFileFullPath, "Delete folder " & $sFileName & " successfully!") EndIf ------------------- DirRemove() Return Value Success: Returns 1. Failure: Returns 0 if there is an error removing the directory (or if directory does not exist). Edited November 24, 2008 by Archer Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 24, 2008 Share Posted November 24, 2008 Does the folder exist? Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Archer Posted November 24, 2008 Author Share Posted November 24, 2008 Does the folder exist?Of course the folder exists. You could refer the script above and the folder was created before DirRemove. Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 24, 2008 Share Posted November 24, 2008 You are aware that DirCreate() can fail as well, right? It doesn't hurt to make sure the folder is created properly before deleting. You check if it exists and write to the log if it does but you try to remove it even if the folder doesn't. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Manko Posted November 24, 2008 Share Posted November 24, 2008 Hi! If NOT DirRemove($sFileName, 0) Then _FileWriteLog($csLogFileFullPath, "Failed to delete folder " & $sFileName) Would work. The @error should be 0 if success. The returnvalue on the other hand should be 1. /Manko Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually... Link to comment Share on other sites More sharing options...
Manko Posted November 24, 2008 Share Posted November 24, 2008 ...or... If @error Then _FileWriteLog($csLogFileFullPath, "Failed to delete folder " & $sFileName) Would work. The @error should be 0 if success. The returnvalue on the other hand should be 1. /Manko Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually... Link to comment Share on other sites More sharing options...
Archer Posted November 24, 2008 Author Share Posted November 24, 2008 You are aware that DirCreate() can fail as well, right? It doesn't hurt to make sure the folder is created properly before deleting. You check if it exists and write to the log if it does but you try to remove it even if the folder doesn't.No. I just wonder to know that the DirRemove() has been successfully removed the folder, why return error code 0?If you run the script you got know that the folder exists but in the next steps, the log show "fail to delete....", just here, why? Link to comment Share on other sites More sharing options...
Archer Posted November 24, 2008 Author Share Posted November 24, 2008 ...or... If @error Then _FileWriteLog($csLogFileFullPath, "Failed to delete folder " & $sFileName) Would work. The @error should be 0 if success. The returnvalue on the other hand should be 1. /Manko Thanks. It works. I wonder to know that why @error = 0 does not work as I expected? Link to comment Share on other sites More sharing options...
Manko Posted November 24, 2008 Share Posted November 24, 2008 Thanks. It works.I wonder to know that why @error = 0 does not work as I expected?Because if @error is 0 it is not an error. /Manko Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually... Link to comment Share on other sites More sharing options...
Archer Posted November 24, 2008 Author Share Posted November 24, 2008 Because if @error is 0 it is not an error. /MankoOhhhhhh, Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now