Exemplo n.º 1
0
        internal static List <Folder> GetRootFolders(MtpDevice device)
        {
            List <Folder> folders = new List <Folder>();

            using (FolderHandle handle = GetFolderList(device.Handle))
            {
                for (IntPtr ptr = handle.DangerousGetHandle(); ptr != IntPtr.Zero;)
                {
                    FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
                    folders.Add(new Folder(folder, device));
                    ptr = folder.sibling;
                }
                return(folders);
            }
        }
Exemplo n.º 2
0
        public List <Folder> GetChildren()
        {
            using (FolderHandle handle = GetFolderList(device.Handle))
            {
                // Find the pointer to the folderstruct representing this folder
                IntPtr ptr = handle.DangerousGetHandle();
                ptr = Find(ptr, folderId);

                FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));

                ptr = f.child;
                List <Folder> folders = new List <Folder>();
                while (ptr != IntPtr.Zero)
                {
                    FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
                    folders.Add(new Folder(folder, device));
                    ptr = folder.sibling;
                }

                return(folders);
            }
        }