How to correctly get the file size of an android.net.Uri?

后端 未结 1 1848
无人共我
无人共我 2021-01-19 10:59

I have an android.net.Uri pointing to a file of which I need to determine the file size. Currently this is done using a query on contentResolver (I am using Xamarin, so it\'

相关标签:
1条回答
  • 2021-01-19 11:23

    Although I did not find out why the query returns incorrect results, I found another way to get the file size which seems to work:

    using (var fd = contentResolver.OpenFileDescriptor(uri, "r"))
        size = fd.StatSize;
    
    0 讨论(0)
提交回复
热议问题