Hi Tracy,
To your question of wildcards in FileDelete(), no the file must be specifically named. I do like what Brad has suggested in his first reply as it gives you some options and flexibility in the event that's important to you and I have used it on occasion. If that's not important to you and you are confident and comfortable deleting an entire directory and all it's contents then, as Chris suggested, issue a DOS command with the Run() function. More specifically, the syntax would look something like this:
Run('CMD /C "RMDIR /S /Q D:\MAIN_FOLDER\sub_folder"', Minimized!)
The /C is to ensure the CMD window terminates. The /S is to include all subfolders and files and the /Q is to prevent the "Are you sure..."
prompt.
Respectfully, I'm less concerned about the safety issue that Brad raises about deleting the wrong directory as well as the concern about interacting with the DOS command for the following reasons:
1) You're already keeping track of the temporary directory and so that would be explicitly stated in the Run() function; should the temporary directory not always be the same or the same full path (EG different users), or you want the flexibility to change it, such that you can't hardcode it in the Run() function then simply build the string for the Run() function using a string variable...so unless I'm misunderstanding Brad's concern, I can't see how you would accidentally delete the wrong directory/ files. My approach has always been to rely on PBScript first in order to accomplish something but I wouldn't hesitate to utilize shelling out to DOS or using Windows API calls if the need/ preference arises.
2) Per the /Q option above (which also works with Del *.*), this will prevent the DOS confirmation prompt and so eliminates any user interaction
As Mike and Miguel have suggested, there is the potential for this to go sideways should there be a crash of the application but I think you can plan for this by ensuring that when you first create the temporary folder it doesn't already exist and if it does then delete it using the same approach as above. Of course, that depends on how you are naming the temporary directory...is it always the same name but maybe a different path per user? Is it always a different name that you're randomly generating but in the same path? Are you coding for multiple users for this functionality? The danger with randomly generated directory names is, over time with multiple crashes, you'll accumulate many orphaned directories/ files that will never be deleted unless you manually look after these after each crash.
HTH...regards,
Mark
In the command window, I type: RMDIR /Q /S "C:\BenchTop10\_New Customer10\PDFMerge"
This works fine
In my code, I build the RUN command:
ls_run = 'RMDIR /Q /S "' + is_currentDir + 'PDFmerge"'
MessageBox("run", ls_run) --- ls_run is exactly the same as what I manually typed into the command line ---
li_rc = RUN(ls_run)
if li_rc = 1 then
this.enabled = FALSE
end if
MessageBox("rc", li_rc)
li_rc is always -1 and the directory is not deleted...
Any ideas?
ls_run = 'CMD /C RMDIR /Q /S "' + is_currentDir + 'PDFmerge"'