Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
We would like to allow a user to use the generic DriveInfo class to get space information and other information about the system drives on mobile systems. Currently, if you call TotalFreeSpace from driveinfo() you get max int64 returned.
foreach (DriveInfo drive in DriveInfo.GetDrives())
var freetest = drive.TotalFreeSpace;
sets freetest = '9223372036854775807'
StatFs stat = new StatFs(Android.OS.Environment.ExternalStorageDirectory.ToString());
var freeSpace = stat.TotalBytes
Returns the free space
DriveInfo.TotalFreeSpace is long.MaxValue because Xamarin.Android isn't using a statfs(2)-based GetDiskFreeSpaceEx(); instead it's using a "stub" GetDiskFreeSpaceEx():
This change was done in:
I *suspect* that this was done because the above commit is from 2009-Jan-18, while the first Android release to support statfs(2) is API-4 Android v1.6, which was released on 2009-Sep-15, so this change would have been required to to enable running mono on API <= 3.
Given that Xamarin.Android only supports API-4+, it should be possible to revert mono/53ce92470 and use statfs(2). We'll look into doing this for a future release.
Fixed in mono/818b81ef and monodroid/afc96c48.
Created attachment 8921 [details]
I have checked this issue and observed that if we call TotalFreeSpace from driveinfo() then it does not return max int64. I am getting the below outputs ;
For device : https://gist.github.com/Rajneesh360Logica/2f8f0f395f196972861f
For Emulator : https://gist.github.com/Rajneesh360Logica/b6631bf397671604db13
I am attaching a sample app which I have created to verify this issue by implementing the code provided in bug description.
Screencast : http://www.screencast.com/t/ov5lpsGTDm2o
Please let me know if I have to check anything else to verify this issue.
Environment Info :
=== Xamarin Studio ===
Version 5.7 (build 596)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Mono 3.12.0 ((detached/b75fa2b)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000046
=== Apple Developer Tools ===
Xcode 6.1 (6604)
=== Xamarin.iOS ===
Version: 126.96.36.199 (Business Edition)
Build date: 2014-11-25 12:12:17-0500
=== Xamarin.Android ===
Version: 188.8.131.52 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
=== Xamarin.Mac ===
Version: 184.108.40.206 (Business Edition)
=== Build Information ===
Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0
=== Operating System ===
Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
> I have checked this issue and observed that if we call TotalFreeSpace from
> driveinfo() then it does not return max int64. I am getting the below outputs ;
Correct; you *shouldn't* be getting long.MaxValue from TotalFreeSpace any more.
> Please let me know if I have to check anything else to verify this issue.
Please run `adb shell df` and ensure that the output from df(1) matches the TotalFreeSpace output your app generates.
I have run the 'adb shell df' and the output from df(1) matches the TotalFreeSpace output your app generates.
Hence closing this issue.
Xamarin Studio 5.9 (build 457)
Xcode 6.2 (6776)
Xamarin.Android : 220.127.116.11 (Enterprise Edition)
Operating System Mac OS X 10.9.4