-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access single file using BclStorageFolder #17276
Comments
Keeping it consistent with UWP, where we initially got these APIs: https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefolder.getitemasync?view=winrt-26100
|
@dmirmilshteyn if you want to add this functionality, a PR is welcome 👐 |
I would be down to implement this but there are some open questions I have because it needs to be implemented for each targeted platform. For Desktop its simple and the name can even be a relative path like mentioned in the UWP docs. Android uses there AndroidUri and you can't just get a File by the Filename (at least what I saw) without iteration over the directory because it abstracts the Filesystem away (items could come for a server, etc). This nullifies the performance gains expected from this issue. The Browser can give you the Item by name I didnt look into IOS. |
On browser this new API should map to: Which gives an idea, that we should consider having two different APIs instead of one shared:
|
On iOS I don't see any dedicated FileManager API. But typical FileInfo C# apis should work there too. On Android, I am not an expert, but seems like the same Query API, as we use for GetItemsAsync(), is recommended there too. |
This proposal is specifically about retrieving single file/folder from the known folder. |
Thank you. I will make an initial implementation with "two different APIs" approach. |
Is your feature request related to a problem? Please describe.
There doesn't seem to be a way to access a single item (file/folder) using the storage folder API. I realize I can find that file using
GetItems
, but in a folder with many files, it would need to enumerate each one before finding the correct file. This has performance problems that only grow with the number of files in a folder.Describe the solution you'd like
I already have the file name I'm looking for, so an addition to the storage folder api that allows me to access a single item with just the name. Something along the lines of
Task<IStorageItem> GetItem(string name)
which does not enumerate through each item in the underlying directory.Describe alternatives you've considered
There's a workaround where I can access an individual file using
IStorageProvider.TryGetFileFromPathAsync
, but I need to manually build a full path and use the storage provider directly instead of the folder. It's also likely not as portable, so not as ideal as having this built-in.Additional context
No response
The text was updated successfully, but these errors were encountered: