获取Android .NET MAUI上的文件的绝对路径

huangapple go评论100阅读模式
英文:

get absolute file path on android .net MAUI

问题

如何获取Android上文件的绝对路径?文件选择器只提供了该文件的缓存路径,这是无用的。我不想使用OpenReadAsync复制文件,因为这可能会导致应用数据变得比必要的更大。有没有其他办法?

英文:

how to get the absolute path of a file on android? the file picker only gives you the cached path of that file which is useless. i don't want to have to copy the file using OpenReadAsync which could lead to app data getting bigger than necessary .is there anyway?

答案1

得分: 0

这似乎是MAUI essentials API的一个错误,因为Android引入了一个新的权限,应该允许应用程序在需要时直接访问文件存储,并且用户允许应用程序这样做。然而,即使应用程序获得了权限,essentials API 也不尝试进行直接读取/写入。

在此处查看并跟踪此问题:https://github.com/dotnet/maui/issues/6015

与此同时,我还在问题评论中发布了一个临时解决方案,直到这个问题得到解决。

英文:

This seems to be a bug with the MAUI essentials API as Android introduced a new permission that should allow applications direct access to file stores if they need it and the user allows the application to do so. However, even with the permission given to the application, the essentials API does not attempt a direct read / write.

Check out and track the issue here: https://github.com/dotnet/maui/issues/6015

I've also posted a work around in the issue comments in the mean time, until this is addressed.

huangapple
  • 本文由 发表于 2023年3月3日 17:59:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75625602.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定