trying to transfer files to a PDA

  • Thread starter Thread starter DanielGifford
  • Start date Start date
D

DanielGifford

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
 
Dan,

Why can't you use Active Sync? Is it because the PDA doesn't support
it? If this is the case, then you will most likely have to use an SDK for
the specific product.
 
Dan,

Why can't you use Active Sync? Is it because the PDA doesn't support
it? If this is the case, then you will most likely have to use an SDK for
the specific product.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




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.

-Dan- Hide quoted text -

- Show quoted text -

I can't use active sync becasue I'm trying to transfer over files to
places that active sync won't let me. I need to do this via my
program. Also, activesync doesn't exactly exist for vista (though
there is a new program that basically does the same thing).
 
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();
 
Hi,

Dan,

Why can't you use Active Sync? Is it because the PDA doesn't support
it? If this is the case, then you will most likely have to use an SDK
for
the specific product.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




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.

-Dan- Hide quoted text -

- Show quoted text -

I can't use active sync becasue I'm trying to transfer over files to
places that active sync won't let me. I need to do this via my
program. Also, activesync doesn't exactly exist for vista (though
there is a new program that basically does the same thing).

I personally have never used ActiveSync, I use RAPI, if you go to
opennetcf.org you will see an extensive list of libraries you can use to
develop apps for PPC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top