- Tracy Lamb
- PowerBuilder
- Sunday, 21 August 2022 02:31 PM UTC
Hi friends,
There are a few places in my App that let as user "attach" a PDF to a specific record. The app creates a directory for the pdf if a matching directory doesn't already exist. Then it copies the selected file and writes a record to the DB.
The user can also delete an "attachment". If the document the user deletes is the only document in the directory, I'd like to delete the directory too. The only thing I can think of is to go ahead and try to remove the directory after each attachment is deleted, trusting that RemoveDirectory () will fail if there are still files in the directory.
li_filenum = RemoveDirectory ( ls_path )
If li_filenum = 1 then
MessageBox("Remove directory succeeded", &
+ "This was the last file in directory: " &
+ ls_path +"~r~nDirectory was removed successfully.")
end if
I'm not sure I even need the MessageBox. If the user adds another file after deleting the last one, the directory will automagically be created again.
Just wondering if there's a smarter way to do this.
~~~Tracy
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.