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 }