Get ParentFolder of a file


your demo works fine, because you go step by step in a folder and save the Folder in variable CurrentFolder.

My problem is, I dive directly in a folder with a known and saved ID of this folder. With this I get all files from the specific folder, but in OnGetFolderList() it seems the AFolderList don't give me the ParentFolder of each file. But I need the ParentFolder as TTMSFNCCloudItem to update (Delete and Upload) the file.

for var a := 0 to AFolderList.Count-1 do
      Memo1.Lines.Add('Filename: ' + AFolderList.Items[a].Filename);
        Memo1.Lines.Add('ParentFolder: ' + AFolderList.Items[a].ParentFolder.Filename);
        Memo1.Lines.Add('PF: except');

How can I get the Parentfolder of the files?


Have you tried using the known ID as the parent folder?

I'm not sure why you would need the parent folder to delete a file as this only requires the TTMSFNCCloudItem of the file itself.
To upload a file you would indeed need a ParentFolder but you could use the same technique by using the known ID.

If the problem persists, can you please let me know which storage service(s) you are using?


I tried several things with FNCOneDrive, but if I use a FolderID and GetFolderListHierarchical(CloudItem) I don't get the CI of ParentFolder and of course also not the foldername of the Folder.

Here is an example. What you have to do, is to set the FolderID of an existing Folder in your environment. In TMemo everytime the output of ParentFolder.Filename is empty. (2.2 KB)

Please note that the GetFolderListHierarchical call only returns the child files and folders of a given folder. This does not include the data of the parent folder. It is expected that this data is known.
The ParentFolder property is only available when iterating through the folder structure of a drive, which implies that the ParentFolder CloudItem was already available from a previous request.

Unfortunately it's currently not supported to retrieve the full CloudItem object of a folder based on it's FolderID.
We'll have to investigate if this is supported in the OneDrive API and if this feature can be added in a future version.