ShareFile-NET icon indicating copy to clipboard operation
ShareFile-NET copied to clipboard

Navigate to File or Folder given Path

Open alexandrugheorghiu opened this issue 9 years ago • 6 comments

How would one go about obtaining the ShareFile.Api.Models.File or the ShareFile.Api.Models.Folder given a path?

E.g., the path can be:

  1. "My Files & Folders/Sample Folder/Sample Sub Folder"
  2. "My Files & Folders/Sample Folder/Sample Sub Folder/default.file"
  3. "Shared Folders/Sample Shared Folder/Sample Shared Sub Folder"
  4. "Shared Folders/Sample Shared Folder/Sample Shared Sub Folder/defaultShared.file"

For now, personally I'm using:

var folder = (ShareFileFolder)await sfClient.Items.Get().Expand("Children").ExecuteAsync();

to get the default folder, or:

var allSharedAlias = sfClient.Items.GetAlias("allshared");
var sharedFolder = await sfClient.Items.Get(allSharedAlias).Expand("Children").ExecuteAsync();
var folder = (ShareFileFolder)await sfClient.Items.Get(sharedFolder.url).Expand("Children").ExecuteAsync();

to get the shared folder. And from there, I'm recursively navigating from one path element to another, until the desired leaf.

Is there another simpler/faster way that's supported by the SDK?

alexandrugheorghiu avatar Sep 07 '15 20:09 alexandrugheorghiu