- Tiago Miranda
- PowerBuilder
- Monday, 25 July 2022 03:51 PM UTC
Hello how are you ?
I'm facing difficulties to delete files with PDF extension generated in a temporary folder on my machine.
These files are generated using the Datawindow/DataStore SaveAs function.
I generate these files and put them in a vector to be able to delete them later. A timer is running that calls the function to delete the files, but when it tries to delete, it returns FALSE and does not delete.
If I try to delete it by entering the folder and delete it, it says that the file is in use by Powerbuilder.
I even used a Yield() Sleep() to see if it worked and it isn't.
It happens that this routine worked and now it doesn't work anymore, the files are always "locked" by the powerbuilder and to be able to delete it I have to close the IDE to delete them from the folder.
LONG nFor
STRING sArrayAux[]
for nFor = 1 to 2
sleep(1)
Yield()
next
FOR nFor = 1 TO UpperBound( i_sApagarArquivo )
IF FileExists ( i_sApagarArquivo[nFor] ) THEN
IF FileDelete( i_sApagarArquivo[nFor] ) THEN
SetNull( i_sApagarArquivo[nFor] )
ELSE
sArrayAux[ UpperBound( sArrayAux ) +1 ] = i_sApagarArquivo[nFor]
END IF
END IF
NEXT
i_sApagarArquivo = sArrayAux
dsDll = CREATE datastore
dsDll.DataObject = "d_rastreamento_laudo_print"
dsDll.SetTransObject( SQLCA )
dsDll.Retrieve(nOsmSerieArr[nAux], nOsmNumArr[nAux], nSmmNumArr[nAux])
IF dsDll.RowCount() > 0 then
sFileHIst = "\smart\temp\" + f_generateGUID() +"_rastreamento.pdf"
dsDll.Object.DataWindow.Export.PDF.Method = NativePDF!
dsDll.SaveAs ( sFileHIst, PDF!, true )
dthrRcls[nAux] = odt.RelativeTime( dthrRcls[nAux], 00:00:03 )
i_s_pdfFiles.sfilename[UpperBound(i_s_pdfFiles.sfilename) + 1] = sFileHIst
i_s_pdfFiles.dtini[UpperBound(i_s_pdfFiles.dtini) + 1] = dthrRcls[nAux]
END IF
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.