Does it always bomb on the same table everytime? What is different about that table? Its settings or anything? I just ran this 10 times successfully in VFP7 SP1:
lncount=0
DO WHILE lncount<10
SET DEFAULT TO c:\programnotes
m.lcDir="c:\temp"
lcTempFile = "c:\programnotes\identity.dbf"
lcTempCDX = "c:\programnotes\identity.cdx"
USE identity
IF FILE(lcTempFile)
lcFile1=m.lcDir+"\identity.DBF"
llReturn=.T.
IF NOT llReturn
RETURN .F.
ENDIF
IF USED("identity")
USE IN identity
ENDIF
DELETE FILE(lcTempFile)
DELETE FILE(lcTempCDX)
IF FILE(lcTempFile)
WAIT WINDOW "Did not delete "+lcTempFile+" successfully!"
ENDIF
ELSE
WAIT WINDOW lcTempFile + " does not exist."
ENDIF
lcFile1=m.lcDir+"\identity.*"
lcFile2="c:\programnotes\*.*"
RUN echo a|xcopy.EXE &lcFile1 &lcFile2
lncount=lncount+1
ENDDO
RETURN
>Using VFP7 sp1 & CodeMine 7.1. (Don't think this has anything to do with CM.)
>Have a form that replaces some free tables with their backup copies. For 4 of the five tables this code works fine. The 5th blows with a Error#3 "File in use" when trying to Delete the table. Am using DataSession=1. Checked the open tables using ADIR() and it's not there. This code is identical in all five routines except for the table names.
>All help appreciated. (I'm outa ideas.)
>Here's the code:
>
>lcTempFile = JUSTPATH(SYS(16,1))+"\data\identity.dbf"
>lcTempCDX = JUSTPATH(SYS(16,1))+"\data\identity.cdx"
>
>IF thisform.CheckFile(lcTempFile) && Does file exist?
> lcFile1=m.lcDir+"\identity.DBF"
> llReturn=thisform.FileInfo(lcFile1, lcTempFile) && Overwrite File?
> IF NOT llReturn
> RETURN .F.
> ENDIF
> IF USED("identity")
> USE IN identity && closes the Table
> ENDIF
> DELETE FILE(lcTempFile) && File in Use Error #3
> DELETE FILE(lcTempCDX) && File in Use Error #3
>ENDIF
>lcFile1=m.lcDir+"\identity.*"
>lcFile2=JUSTPATH(SYS(16,1))+"\data\"
>*WAIT WINDOW "XCOPY ["+lcFile1+"] ["+lcFile2+"]"
>RUN xcopy.exe &lcFile1 &lcFile2
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"