获取磁盘空间大小

 

RT:

-(float)getTotalDiskSpaceInBytes {  

    float totalSpace = 0.0f;  

    NSError *error = nil;  

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  

    NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];  

 

    if (dictionary) {  

        NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];  

        totalSpace = [fileSystemSizeInBytes floatValue];  

    } else {

       NSLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]);  

    }  

 

    return totalSpace;  

 

posted @ 2010-02-08 11:57  javawebsoa  Views(231)  Comments(0Edit  收藏  举报