2010-02-24 3 views
2

PDA에서 찾은 파일을 복사해야하는 프로젝트가 있습니다 (필자의 경우 MC3000이 차이가있을 경우). ActiveSync가 설치되어 있고 syncronisation 폴더를 만들었습니다. 그러나, 나는 그것의 MyDocument 폴더뿐만 아니라 PDA의 콘텐츠를 읽을 수 있도록하고 싶습니다 (플러스 20 + 가능한 PDA를 같은 모델의, 따라서 20 + 디렉토리를 만들고 작동 할 수 없다)ActiveSync와 동기화되는 동안 PDA 디렉토리 내용 읽기

도킹 된 상태에서 ActiveSync와 동기화되는 동안 PDA 내부에서 IO를 수행하는 방법이 있습니까?

탐색기에서 '모바일 장치'를 볼 수 있습니다.

감사

답변

3

사용 RAPI. Rapi.dll 및 ActiveSync에 대해 관리되는 래퍼 클래스를 제공하는 코드 플렉스 프로젝트입니다. 그것은 데스크톱 .NET 애플 리케이션이 속박 된 모바일 장치와 통신 할 수 있습니다. 래퍼는 OpenNetCF project에서 시작되었지만 이제 별도로 관리됩니다.

해당 프로젝트에서 제공되는 전체 RAPI 프로젝트 DLL을 사용하거나 필요한 코드의 서브 세트 만 사용할 수 있습니다. 연결되었을 때 장치에 파일을 만들 필요가있어서 성능 통계 항목이나 Rapi에 포함 된 장치 레지스트리 항목이 필요하지 않았습니다.

  • 사용 ActiveSync를 (DccManSink)는 모바일 장치 연결/해제 상태
  • 사용을 감지 : 그래서 그냥이가,

    나를 위해 작동 방법 내가 필요한 3 개 소스 파일을 ... 잡고 장치에 파일을 복사하고 장치에서 파일을 작성하며 장치에서 파일을 복사하는 RAPI 랩퍼.


private DccMan DeviceConnectionMgr; 
private int AdviceCode; 
private int ConnectionStatus = 1; 
private System.Threading.AutoResetEvent DeviceConnectionNotification = new System.Threading.AutoResetEvent(false); 


public void OnConnectionError() 
{ 
    ConnectionStatus = -1; 
    DeviceConnectionNotification.Set(); 
} 

public void OnIpAssigned(int address) 
{ 
    ConnectionStatus = 0; 
    DeviceConnectionNotification.Set(); 
} 


private void btnCopyToDevice_Click(object sender, EventArgs e) 
{ 
    // copy the database (in the form of an XML file) to the connected device 
    Cursor.Current = Cursors.WaitCursor; 

    // register for events and wait. 
    this.DeviceConnectionMgr = new DccMan(); 

    DccManSink deviceEvents = new DccManSink(); 
    deviceEvents.IPChange += new IPAddrHandler(this.OnIpAssigned); 
    deviceEvents.Error += new ErrorHandler(this.OnConnectionError); 
    ((IDccMan)DeviceConnectionMgr).Advise(deviceEvents, out this.AdviceCode); 

    // should do this asynchronously, with a timeout; too lazy. 
    this.statusLabel.Text = "Waiting for a Windows Mobile device to connect...."; 

    this.Update(); 
    Application.DoEvents(); // allow the form to update 

    bool exitSynchContextBeforeWait = false; 
    DeviceConnectionNotification.WaitOne(SECONDS_TO_WAIT_FOR_DEVICE * 1000, exitSynchContextBeforeWait); 

    if (ConnectionStatus == 0) 
    { 
     this.statusLabel.Text = "The Device is now connected."; 
     this.Update(); 
     Application.DoEvents(); // allow the form to update 

     RAPI deviceConnection = new RAPI(); 
     deviceConnection.Connect(true, 120); // wait up to 2 minutes until connected 
     if (deviceConnection.Connected) 
     { 
      this.statusLabel.Text = "Copying the database file to the connected Windows Mobile device."; 
      this.Update(); 
      Application.DoEvents(); // allow the form to update 
      string destPath = "\\Storage Card\\Application Data\\MyApp\\db.xml"; 
      deviceConnection.CopyFileToDevice(sourceFile, 
               destPath, 
               true); 

      this.statusLabel.Text = "Successfully copied the file to the Windows Mobile device...."; 
     } 
     else 
     { 
      this.statusLabel.Text = "Oh, wait, it seems the Windows Mobile device isn't really connected? Sorry."; 
     } 

    } 
    else 
    { 
     this.statusLabel.Text = "Could not copy the file because the Device does not seem to be connected."; 
    } 

    Cursor.Current = Cursors.Default; 

} 
+0

내가 필요 정확히 같은 소리! 그러나 아직 테스트 할 수 없습니다. 필자는 PDA에서 특정 디렉토리에있는 파일 만 가져올 필요가 있기 때문에 작동하는 것 같습니다. –

+0

이 작품을 만드는 데 문제가 있습니다. 어떤 종류의 프로젝트를 사용하고 있습니까? 내가 알아야 할 코드에없는 것 ...? 저는 특히 DCCMan 또는 AdviceCode 유형의 것을 만들 수 없습니다. 감사합니다. . –

+0

Whadaya mean? "타입의 무엇이라도 만들어라. ..". codeplex.com의 RAPI 프로젝트 코드가 필요합니다. 그거 맞지? DccManSink 및 RAPI와 같은 클래스는 해당 코드에서 정의됩니다. AdviceCode는 단지 int입니다. (예, 나는 작업 프로젝트에서이 코드를 발췌 할 때 실수로 그것을 버렸습니다) – Cheeso