From http://blog.csdn.net/txinfo/article/details/7347515
A small local file management function is usually used to obtain the sandbox directory and file list of an application. However, it is rarely mentioned on the Internet to obtain the specified file size, after reading the source code for half a day, I found the place. Here I share it:
Nsfilemanager* FM= [Nsfilemanager Defamanager Manager];
//File Size
Nserror* Error =Nil;
Nsdictionary* Dictfile = [[FMAttributesofitematpath: FullfileError: & Error]Retain];
If(Error)
{
Nslog(@ "Getfilesize error: % @", Error );
Return No;
}
LongNfilesize = [dictfileFilesize]; // Get the file size
[DictfileRelease];
InIn the nsdictionary statement, you can also find the file modification time, file type, and other information.
@ InterfaceNsdictionary (nsfileattributes)
-(Unsigned Long Long) Filesize;
-(Nsdate*) Filemodificationdate;
-(Nsstring*) Filetype;