By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,939 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,939 IT Pros & Developers. It's quick & easy.

trying to transfer files to a PDA

P: n/a
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

Jul 25 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

<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

Jul 25 '07 #2

P: n/a
On Jul 25, 8:46 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com

<DanielGiff...@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- 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).

Jul 25 '07 #3

P: n/a
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

Jul 25 '07 #4

P: n/a
Hi,

<Da***********@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
On Jul 25, 8:46 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>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]
- m...@spam.guard.caspershouse.com

<DanielGiff...@gmail.comwrote in message

news:11**********************@x40g2000prg.googleg roups.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- 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
Jul 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.