日期:2014-05-19  浏览次数:21073 次

【ce问题求问】从wince拷贝文件到pc的问题
String   RemoteFileName2   =   @ "\Application\stwms\receive.txt ";   //   远程设备文件名2
private   const   uint   GENERIC_READ   =   0x80000000;
private   const   short   FILE_ATTRIBUTE_NORMAL   =   0x80;   //   设置文件属性
String   LocalFileName   =   @ "c:\test.txt ";   //   本地计算机文件名FileStream   localFile;
int   bytesread   =   0;

remoteFile2   =   CeCreateFile(RemoteFileName2,   GENERIC_READ,   0,   0,   1,   FILE_ATTRIBUTE_NORMAL,   0);
                long   iresult   =   CeReadFile(remoteFile,   readbuffer,   4096,   ref   bytesread,   0);
                //   检查文件是否读取成功
                if   ((int)remoteFile2   ==   INVALID_HANDLE_VALUE)
                {
                        throw   new   Exception( "Could   not   read   remote   file ");
                }
                localFile   =   new   FileStream(LocalFileName,   FileMode.Open);
                //   读取4K字节
                localFile.Write(readbuffer,   0,   readbuffer.Length);
                localFile.WriteByte(readbuffer);
                localFile.Close();
                //   关闭远程文件
                CeCloseHandle(remoteFile);

[DllImport( "rapi.dll ",   CharSet   =   CharSet.Unicode,   SetLastError   =   true)]
        internal   static   extern   IntPtr   CeCreateFile(string   lpFileName,   uint   dwDesiredAccess,   int   dwShareMode,   int   lpSecurityAttributes,   int   dwCreationDisposition,   int   dwFlagsAndAttributes,   int   hTemplateFile);
[DllImport( "rapi.dll ",   CharSet   =   CharSet.Unicode)]
        internal   static   extern   int   CeReadFile(IntPtr   hFile,   byte[]   lpBuffer,   int   nNumberOfBytesToRead,   ref   int   lpNumberOfBytesRead,   int   lpOverlapped);
-------------------------------
就是想把ce中的一个文件拷贝到pc里,现在的问题是remoteFile2始终为-1,总是抛出“Could   not   read   remote   file”的异常,大家帮忙看看哪儿错了,或者谁能给个例子,刚学ce的编程,很多不清楚

------解决方案--------------------
不会,关注一下
------解决方案--------------------
这个要关注下,楼住解决要说下.顶
------解决方案--------------------
是否没有权限