Home
Manage Your Code
Snippet: PocketPC FileRetriever via ActiveSync (C#)
Title: PocketPC FileRetriever via ActiveSync Language: C#
Description: This snippet retrieve all files in the specified folder of a repote PocketPC device connected via ActiveSync. Views: 1350
Author: Diego Guidi Date Added: 5/9/2006
Copy Code  
1		/// <summary>

2		/// Retrieve all files in the specified folder of a repote PocketPC device connected via ActiveSync.

3		/// </summary>

4		/// <param name="searchPath">Remote folder in a PocketPC device.</param>

5		private void SearchFiles(string searchPath)
6		{
7			Debug.Assert(rapi != null);	// member referring to a OpenNETCF.Desktop.Communication.Rapi object

8			Debug.Assert(rapi.Connected);	// test if PocketPC device is already connected

9
10			FileList list = rapi.EnumFiles(searchPath + @"\\*");
11			foreach(FileInformation file in list)
12			{
13				if(file.FileAttributes  == 16)	     // Is a directory: recursive search...

14					SearchFiles(searchPath + "\\" + file.FileName);	
15				else if(file.FileAttributes  == 32)  // Is a file: add to a list...

16					filesPathsList.Add(searchPath + "\\" + file.FileName);
17				else throw new ArgumentException
18					("FileAttributes unknown: " + file.FileAttributes, "file.FileAttributes");
19			}
20		}
Usage
Simply call the method using the initial of the remote folder.
It's necessary a reference the OpenNETCF.Desktop.Communication.dll for using RAPI object.