I use this method to get the free space of the device (find it on the network):
-(float)getFreeSpace{
float freeSpace = 0.0f;
NSError *error = nil;
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:kSongsFolder error: &error];
if (dictionary) {
NSNumber *fileSystemFreeSizeInBytes = [dictionary objectForKey: NSFileSystemFreeSize];
NSLog(@"%d",fileSystemFreeSizeInBytes);
freeSpace = [fileSystemFreeSizeInBytes floatValue];
} else {
}
return freeSpace/1024;
}
now I get 8687616.0 from this method, and when I check the properties of the device, I have 8.1 GB for free.
How can I get free space in MB? and this method was good because there is something else between them.
source
share