1. RITESH KUMAR
  2. PowerBuilder
  3. Thursday, 21 November 2024 10:31 AM UTC

Hi Team,

I am encountering an issue while attempting to delete a .pdf file generated in a temporary folder on my machine. Below are the steps to replicate the problem:

  1. Copy the contents of the file into a blob variable.
  2. Create a .pdf file in the temporary folder (e.g., C:/temp/).
  3. Create a window (w_main, type: main window) containing an OLE control named Microsoft Web Browser to display the .pdf file using the file path URL (e.g., C:/temp/samplefile.pdf).
  4. Open the w_main window within the MDI application.
  5. In the Open event of the w_main window, write code to display the .pdf file in the OLE control.
  6. After the w_main window is open, click 2-3 times outside the PowerBuilder application on the desktop (e.g., right-click and refresh).
  7. In the Close event of the w_main window, attempt to delete the temporary .pdf file using the FileDelete function.

Here is a snippet of the code used in the Close event:

Boolean lb_val Long ll_handle ll_handle = Handle(ole_wbc) If NOT IsNull(ll_handle) Then Send(ll_handle, 16, 0, 0) End If lnv_cst_filesrv.of_getfileattributes(as_filePath, lb_ReadOnly, lb_Hidden, lb_System, lb_SubDirectory, lb_Archive) // Unset Read-Only property If lb_ReadOnly Then li_result = lnv_cst_filesrv.of_setfilereadonly(as_filePath, False) End If lb_val = FileDelete(as_filePath)

Issue:
The FileDelete function returns false for the above code.

Observations:

  1. If a message box is added before the FileDelete call, the file is successfully deleted.
  2. Clicking outside the PowerBuilder application and then closing the w_main window seems to lock the file, possibly due to Adobe Acrobat Reader.
  3. I tried using Yield() and Sleep() functions before FileDelete, but they didn’t resolve the issue.
  4. I have check the permissions as well which is not the issue in this case. 
  5. Filedelete returns false only when I click anywhere on machine outside the Powerbuilder Application.
  6. Issue is replicated on PB2019 R3, PB2022 R3 

Could you please help us to identify the root cause of this issue and if possible please suggest a solution?

Best regards,
Ritesh Kumar

Who is viewing this page


There are no replies made for this question yet.
However, you are not allowed to reply to this question.