When I try getting the Path from the IStorageItems passed back to me from a Share Target’s GetStorageItemsAsync() call when sharing from the Windows 8 Photos app, the Path property for all items returned is empty. The Name (filename) is properly populated. However, I need the actual Path, and there doesn’t appear to be a way to get it.
Is this a bug in Windows 8’s Photos app, or am I doing something wrong?
My code to get the list of items:
this.sharedStorageItems = await this.shareOperation.Data.GetStorageItemsAsync();
My code to iterate through the list:
// Display the name of the files being shared.
var files = new List<String>();
for (int index = 0; index < this.sharedStorageItems.Count; index++)
files.Add(String.Concat(this.sharedStorageItems[index].Path, "\\", this.sharedStorageItems[index].Name));
The Path above is always empty.
It appears the IStorageItem is simply the base class. What’s REALLY being returned is an IStorageFile, which includes the base stream of a temporary file created as part of the share process.
So, cast the IStorageItem as an IStorageFile and you’ll be in good shape to work with the files returned.