Hi,
Yes, of course, you have to use RAPI.
Here is the code to copy a file
public static void CopyFileToPDA(string localfile, string remotefile)
{
//First Copy the executable
int fileh= RAPI.CeCreateFile(remotefile, RAPI.GENERIC_WRITE, 0, 0,
RAPI.CREATE_ALWAYS, RAPI.FILE_ATTRIBUTE_NORMAL, 0);
if ( fileh == 0)
throw new Exception("Error Creating Remote File : " );
FileStream reader = new FileStream(localfile,FileMode.Open);
byte[] buff = new Byte[ 400096];
int readed = 0;
int written=0;
while( (readed=reader.Read( buff, 0, 400096))>0)
RAPI.CeWriteFile( fileh, buff, readed, out written, 0);
RAPI.CeCloseHandle( fileh);
reader.Close();
}
public static void RapiInit()
{
try
{
if ( !isRAPIOpen)
CeRapiInit ();
isRAPIOpen = true;
}
catch(Exception e)
{
isRAPIOpen = false;
}
}
public static void RapiUninit ()
{
if ( isRAPIOpen )
CeRapiUninit();
isRAPIOpen = false;
}
These are the p/invoke that you need.
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeDeleteFile(string remotefile);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCloseHandle(int hObject);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateFile(string lpFileName,uint
dwDesiredAccess,int dwShareMode,int lpSecurityAttributes,int
dwCreationDisposition,int dwFlagsAndAttributes,int hTemplateFile);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeRapiInitEx ([MarshalAs(UnmanagedType.Struct)]
ref RAPIINIT pRapiInit);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
protected static extern int CeRapiInit ();
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
protected static extern int CeRapiUninit ();
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeReadFile(int hFile,byte[] lpBuffer,int
nNumberOfbytesToRead, out int lpNumberOfbytesRead, int lpOverlapped);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeWriteFile(int hFile,byte[] buffer, int
nNumberOfbytesToWrite, out int lpNumberOfbytesWritten, int lpOverlapped);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeGetLastError();
<Da***********@gmail.comwrote in message
news:11**********************@x40g2000prg.googlegr oups.com...
Hi-
I'm trying to transfer files directly to a PDA via a Csharp program
I'm writing. Does anyone know how to do this (I obviously can't use
active sync).
Ohh yes, I'm running Vista.
-Thanks
-Dan