1. Determine whether the file in the bundle exists
-(Bool) judgefileexist :( nsstring *) filename
{
// Obtain the file path
Nsstring * Path = [nsbundle
Mainbundle] pathforresource: Filename
Oftype: @ ""];
If (Path = NULL)
Returnno;
Returnyes;
}
2. Check whether the file in doucuments exists.
-(Bool) judgefileexist :( nsstring *) filename;
{
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes );
Nsstring * documentsdirectory = [paths objectatindex: 0];
Nsstring * filepath = [documentsdirectory stringbyappendingpathcomponent: Filename];
Nsfilemanager * filemanager = [nsfilemanagerdefaultmanager];
Return [filemanager fileexistsatpath: filepath];
}
3. Obtain the file path.
-(Nsstring *) imagefilepath :( nsstring *) filenname
{
// Nsstring * paths = [nshomedirectory () stringbyappendingpathcomponent: @ "documents"];
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes );
Nsstring * documentsdirectory = [paths objectatindex: 0];
Return [documentsdirectory stringbyappendingpathcomponent: filenname];
}