Can't delete a file on a CE Device

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a Pocket PC 2003, which has a folder in the root called
\Application. Below this I have another folder with data files. I am using
VB6 with the Rapi.dll to copy files from this folder to my desktop. Then
when I try to delete a file on the Device using the CeDeleteFile api, I get a
CeGetlastError =2, or ERROR_FILE_NOT_FOUND error. I don't understand this
because I reference this file in order to copy it, but I cannot delete it???
I am not opening it, just copying it. I also tried to delete another file in
the same folder that I was not referencing, but I could not delete that also.

Any suggestions would be appreciated,

Thanks in advance,

WayneM
 
Chris,

Here is the code,

' get the directory file
XferDirectoryFileName = "ScannedXferFilesDir.txt"

ScannerDirectoryFileNameOnScanner = ScannerFilePath &
XferDirectoryFileName
ScannerDirectoryFileNameOnPC = PCFilePath & XferDirectoryFileName

' check to see if there is an old directory file, if so delete it
If FileExists(ScannerDirectoryFileNameOnPC) Then
On Error Resume Next
Kill ScannerDirectoryFileNameOnPC
On Error GoTo cmdLoadTransfers_ClickError
End If

' copy the directory file to the PC
Call RAPICopyCEFileToPC(ScannerDirectoryFileNameOnScanner,
ScannerDirectoryFileNameOnPC, BytesCopiedUp)
If BytesCopiedUp = 0 Then
MsgBox "No data transferred from scanner to PC.", vbInformation
Exit Sub
End If

' loop to transfer each file
Set dirFile = fs.GetFile(ScannerDirectoryFileNameOnPC)
Set ts = dirFile.OpenAsTextStream(ForReading)
Do
NextLine = ts.ReadLine

TransferSheetsCreated = TransferSheetsCreated &
txtTransferSheetNumber.Text & ", "
Call RAPICopyCEFileToPC(ScannerFilePath & NextLine, PCFilePath &
NextLine, BytesCopiedUp)
If BytesCopiedUp > 0 Then
Set nextFileToProcess = fs.GetFile(PCFilePath & NextLine)
Set tsForUpdate = nextFileToProcess.OpenAsTextStream(ForReading)
NextLineToProcess = tsForUpdate.ReadLine
NewInfo = Split(NextLineToProcess, "|")
TransferDateTime = NewInfo(3)
Do
NextLineToProcess = tsForUpdate.ReadLine

NewInfo = Split(NextLineToProcess, "|")
Set rs = DISDb.OpenRecordset("Select * from ItemMaster Where
UPC=" & NewInfo(UPCndx), dbOpenSnapshot)
If Not IsNull(rs.Fields("ItemID")) Then
curItemID = rs.Fields("ItemID")
Else
curItemID = ""
End If
If Not IsNull(rs.Fields("Department")) Then
curDepartment = rs.Fields("Department")
Else
curDepartment = Null
End If
If Not IsNull(rs.Fields("Cost")) Then
curCost = rs.Fields("Cost")
Else
curCost = Null
End If
rs.Close
NewInfo(Descriptionndx) = Replace(NewInfo(Descriptionndx),
"'", "''")
NewInfo(Descriptionndx) = Left(NewInfo(Descriptionndx), 50)
NewInfo(Vendorndx) = Replace(NewInfo(Vendorndx), "'", "''")
insertStmt = "Insert into TransferSheets (XferSheetNo, UPC,
VendorName, Description, ItemID, TransferDate,"
insertStmt = insertStmt & "SendingUID, FromLoc, ToLoc,
QtyTransferred, Cost, QtyReceived, TotalPrice) Values("
insertStmt = insertStmt & Val(txtTransferSheetNumber.Text) &
"," & Val(NewInfo(UPCndx)) & ",'" & NewInfo(Vendorndx) & "','" &
NewInfo(Descriptionndx) & "','" & curItemID & "','"
insertStmt = insertStmt & TransferDateTime & "','" &
SendingUID & "','" & NewInfo(FromLocndx) & "','" & NewInfo(ToLocndx) & "'," &
NewInfo(QtyTransferredndx) & "," & curCost & ",''," &
Val(Format(Val(NewInfo(QtyTransferredndx) * curCost), "0.00")) & ")"
DISDb.Execute insertStmt, dbSQLPassThrough
NumOfXfers = NumOfXfers + 1
If tsForUpdate.AtEndOfStream Then Exit Do

Loop
tsForUpdate.Close
' now rename it, but first check to see if it already exists
If FileExists(PCFilePath & "Old_" & NextLine) Then
result = MsgBox("The file " & "Old_" & NextLine & " already
exists on the PC. Do you want it deleted?", vbYesNo)
If result = vbYes Then
Kill PCFilePath & "Old_" & NextLine
Else
Exit Sub
End If
End If
nextFileToProcess.Name = "Old_" & NextLine

End If
' now delete the files

result = CeDeleteFile(ScannerFilePath & NextLine)

In the code above, I can find, transfer and then process the file with the
Call RAPICopyCEFileToPC, but then when I am finished and try to delete with
the last line, I get a error = 2, file can't be found. It doesn't say the
file can't be accessed or permission denied or something like that.

Thanks for any suggestions,

WayneM
 
Back
Top