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

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 21 November 2024 18:14 PM UTC
  2. PowerBuilder
  3. # 1

Hi Ritesh;

  I suspect that the FileDelete command fails because there is still a file lock on the PDF due to using the OLE control that then uses the Microsoft Web Browser. The Microsoft Web Browser is most likely the cause as it's now a very old and deprecated Internet Explorer "plug-in". This is most likely the cause (my guess).

  I would suggest that your App stop using the OLE route and try the built-in PB Web Browser" control for this functionality. It's based on the Microsoft WebView2 control which is the replacement for IE OLE control in both W10 & W11 (and higher) O/S versions.  HTH

Regards .. Chris

Comment
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 21 November 2024 14:58 PM UTC
  2. PowerBuilder
  3. # 2

Hi Ritesh,

 

If you can reproduce this on 2022 R3 you should open a support ticket reporting this: https://www.appeon.com/standardsupport/search

Please provide a reproducible test case with which the problem can be observed easily. This will tremendously help our engineers.

 

Regards,
Francisco

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.