We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Bobby I's avatar
Bobby I
Explorer | Level 4
5 years ago

Calculating folder size using C# SDK

I was looking into calculating total file size within a folder programmatically for display purposes. I have a method that calls DropboxClient.ListFoldersAsync with the path and recursive set to true, then iterate through each of the objects that are MetaData.IsFile and adds the size. The FileMetaData.Size for .paper or .gdoc file types always have the same value (ulong 75), so it makes me believe it is a pointer to where the file is actually stored. I looked into the Network tab when clicking Calculate Size in Dropbox and saw it made a request to

https://www.dropbox.com/2/folders/get_subfolder_sizes_in_same_namespace

and

https://www.dropbox.com/2/folders/get_shared_subfolder_sizes

Is there a way to get the actual file size for these cloud file types, or is there a helper method in the Dropbox SDK to achieve the same calculations as is possible through Dropbox's GUI?

  • No, unfortunately I can't think of any other workarounds for this.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The public Dropbox API doesn't offer a direct way to get the total size of a folder, or to get the size of cloud file content, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. The functionality you found on the web site is not part of the public Dropbox API unfortunately.

    • Bobby I's avatar
      Bobby I
      Explorer | Level 4

      I see, that's too bad. Has there been any decent workarounds you have encountered to simulate this functionality using the public API? I guess there is a reason Dropbox hasn't implemented this just yet publicly, so maybe this question is too forward.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        No, unfortunately I can't think of any other workarounds for this.