Firstly, sorry if this is in the wrong area, but this seemed to be the more
active area.
I have searched everywhere, both here and via google for an answer on how to
use the CeCopyFile function in VB but I can not find the answer I am looking
for.
I have an Access database I use to push and pull files to and from the PDA to
a network server using the functions as provided by Microsoft that everyone
seems to use. This works fantastic as I use a table to define the files and
paths to complete the transfer of the data to and from.
I was asked the other day if I could backup the files on the PDA to itself
prior to a transfer of the files from the PDA to the network as a means of
safe guarding the data a little more. After a quick google search it appears
the CeCopyFile is the way to go and I realise that this only copies files
from one location on the PDA to another, which is exactly what i want.
The problem is that i do not know how to implement the code in Access to get
it to work!
I have the following code at the moment
<CODE>
Public Declare Function CeCopyFile Lib "rapi.dll" ( _
ByVal CurrentPath As String, _
ByVal NewPath As String, _
ByVal Overwrite As Boolean) As Long
</CODE>
I use this funtion in a custom function to pass the variables
<CODE>
Public Function buFiles(sOLoc As String, sDLoc As String, bFailIfExists As
Boolean)
'bFailIfExists = True if you DO NOT want to overwrite!
If Not RapiIsConnected Then
MsgBox "Device is not connected. Please connect first."
Exit Function
End If
'Do the file copy
Dim lBU As Long
lBU = CeCopyFile(sOLoc, sDLoc, bFailIfExists)
'Check CeGetLastError
Dim lLastError As Long
If lBU = False Then
lLastError = CeGetLastError()
End If
Select Case lLastError
Case ERROR_FILE_EXISTS
MsgBox "A file already exists with the specified name."
Case ERROR_INVALID_PARAMETER
MsgBox "A parameter was invalid."
Case ERROR_DISK_FULL
MsgBox "Disk if Full."
Case 32
MsgBox "File access error. It is possible that Arcpad in your
mobile device is still running." & vbCrLf & "Please close the Arcpad in the
mobile device and try again."
Case Else
MsgBox "An unknown error occured."
End Select
End Function
</CODE>
When I run this function ( ?buFiles("\Temp\CannedText.txt", "\Temp\BU\
CannedText.txt", False) ) in the Immediate Window (Ctrl + G) it gives me an
error message where the error number is '2' which when looking at the RAPI
documentation relates to a "Can not find file location" error.
Can someone please point me in the right direction as to why it can not find
the location on the PDA or where else I might not be calling the function
correctly.
Cheers
Dave - inf3rno