Hi,
I can copy file from desktop to device.
But when I put out pocket pc from computer then again put on pocket pc to
computer, my program never copy file again. CeCreateFile method returns -1
value.
I have to close application then run again to copy file.

Any help will be appreciated.

Sample code

CeRapiInit;
FStream := TFileStream.Create(XMLFile, fmOpenRead + fmShareDenyNone);
try
DataStream := FStream;
try
StringToWideChar('\My Documents\NetsimSS\' + XMLFile, Name,
Sizeof(Name));
Handle := CeCreateFile(Name,GENERIC_WRITE,FILE_SHARE_READ,
nil,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if Handle <> -1 then
begin
while not (DataStream.Position = DataStream.Size) do
begin
if (DataStream.Size - DataStream.Position) >= BlockSize then
Size := BlockSize
else
Size := DataStream.Size - DataStream.Position;
DataStream.Read(Buffer, Size);
Trim(Buffer);
if not CeWriteFile(Handle, @Buffer, Size, NumberOfBytesWritten,
nil) then
ShowMessage(SysErrorMessage(GetRapiError));
end;
if not CeCloseHandle(Handle) then
ShowMessage(SysErrorMessage(ceGetLastError));
end
except
on e:Exception do
ShowMessage(e.Message);
end;
finally
FStream.Free;
CeRapiUnInit;
end;





--
Harun BOLAT

Re: CopyFileDesktopToDevice by Chris

Chris
Fri Jun 18 09:35:17 CDT 2004

I think you're using C#, so I'm going to recommend not reinventing the wheel
on this:

www.opennetcf.org/communication

-Chris


"Harun Bolat" <harunbolat@kaynet.net> wrote in message
news:%23PnsviSVEHA.2520@TK2MSFTNGP12.phx.gbl...
> Hi,
> I can copy file from desktop to device.
> But when I put out pocket pc from computer then again put on pocket pc to
> computer, my program never copy file again. CeCreateFile method returns -1
> value.
> I have to close application then run again to copy file.
>
> Any help will be appreciated.
>
> Sample code
>
> CeRapiInit;
> FStream := TFileStream.Create(XMLFile, fmOpenRead + fmShareDenyNone);
> try
> DataStream := FStream;
> try
> StringToWideChar('\My Documents\NetsimSS\' + XMLFile, Name,
> Sizeof(Name));
> Handle := CeCreateFile(Name,GENERIC_WRITE,FILE_SHARE_READ,
> nil,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
> if Handle <> -1 then
> begin
> while not (DataStream.Position = DataStream.Size) do
> begin
> if (DataStream.Size - DataStream.Position) >= BlockSize then
> Size := BlockSize
> else
> Size := DataStream.Size - DataStream.Position;
> DataStream.Read(Buffer, Size);
> Trim(Buffer);
> if not CeWriteFile(Handle, @Buffer, Size, NumberOfBytesWritten,
> nil) then
> ShowMessage(SysErrorMessage(GetRapiError));
> end;
> if not CeCloseHandle(Handle) then
> ShowMessage(SysErrorMessage(ceGetLastError));
> end
> except
> on e:Exception do
> ShowMessage(e.Message);
> end;
> finally
> FStream.Free;
> CeRapiUnInit;
> end;
>
>
>
>
>
> --
> Harun BOLAT
>
>



Re: CopyFileDesktopToDevice by Harun

Harun
Sat Jun 19 06:37:10 CDT 2004

thank you very much.
I found problem that ceRapiUnInit could not execute.
if rapi uninitialize, no problem occur when I try copy file to different
device terminating application.


> I think you're using C#, so I'm going to recommend not reinventing the
wheel
> on this: