Пример #1
0
        public void DeleteFile(PortableDevice device, String name)
        {
            PortableDeviceFile fileToDelete = null;

            try
            {
                foreach (var file in Files)
                {
                    if (file is PortableDeviceFile && name.Equals(file.Name))
                    {
                        fileToDelete = (PortableDeviceFile)file;
                        break;
                    }
                }

                // Got file?
                if (null != fileToDelete)
                {
                    device.DisconnectConnect();
                    device.DeleteFile(fileToDelete);
                    Files.Remove(fileToDelete);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                device.Disconnect();
            }
        }
Пример #2
0
        public static void DisplayFolderContents(PortableDevice device, PortableDeviceFolder folder)
        {
            foreach (var item in folder.Files)
            {
                Console.WriteLine(item.Name);
                if (item is PortableDeviceFile)
                {
                    device.DownloadFile((PortableDeviceFile)item, @"F:\t_tmp\");
                }

                if (item is PortableDeviceFile)
                {
                    device.DeleteFile((PortableDeviceFile)item);
                }

                if (item is PortableDeviceFolder)
                {
                    DisplayFolderContents(device, (PortableDeviceFolder)item);
                }
            }
        }
Пример #3
0
 //---------------------------------------------------------------------------------------------------------
 public static void DisplayFolderContents(PortableDevice device, PortableDeviceFolder folder)
 {
     foreach (var item in folder.Files)
     {
         //Console.WriteLine("item: " + item);
         if (item is PortableDeviceFolder)
         {
             //Console.WriteLine("Folder: " + item.Id);
             DisplayFolderContents(device, (PortableDeviceFolder)item);
         }
         if (item is PortableDeviceFile)
         {
             if (!Directory.Exists(outputDir))
             {
                 Directory.CreateDirectory(outputDir);
             }
             Console.WriteLine("file: " + item.Name);
             //device.DownloadFile((PortableDeviceFile)item, @"K:\testCam\");
             device.DownloadFile((PortableDeviceFile)item, outputDir);
             //once its downloaded, delete the copy on the camnera
             device.DeleteFile((PortableDeviceFile)item);
         }
     }
 }