0
我正在使用文件管理器來檢查文件的大小,代碼在模擬器上工作正常,但是當我在iPhone上運行相同的應用程序時,它說文件大小爲零,即使文件大小大於零,我使用以下代碼:在我的iPhone應用程序中的文件管理器
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory1 = [paths1 objectAtIndex:0];
documentsDirectory1 = [documentsDirectory1 stringByAppendingPathComponent:@"XML"];
NSString * szDestPath1 = [documentsDirectory1 stringByAppendingPathComponent:@"Extras"];
NSString *URL2 = [szDestPath1 stringByAppendingPathComponent:@"config.xml"];
NSLog(@"%@",URL2);
NSError *attributesError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:URL2 error:&attributesError];
int _fileSize = [fileAttributes fileSize];
NSLog(@"_fileSize:%U",_fileSize); //0 if empty
我該如何解決這個問題,誰能幫助我? thanx提前。
您的格式有點上的代碼打破。閱讀這樣的非格式化代碼非常困難。你能幫我們解決嗎?謝謝。 – 2011-03-24 12:12:26