title: Unable to read files in resources folder - iOS
body: <p>I am trying to read a file placed in a directory <code>Object Bank</code>, inside the resources folder.</p>
  
  <pre><code>//Get path for file in object bank
  NSString* path = [[NSBundle mainBundle] pathForResource:fileId ofType:@"eam" inDirectory:@"Object Bank"];
  NSError *error=nil;
  
  //Check if it is present at the location
  Boolean prepositioned=[[NSFileManager defaultManager] fileExistsAtPath:path];
  NSLog(@"File Found : %@",prepositioned?@"Yes":@"No");
  
  //This outputs "File Found : Yes"
  
  //Read file
  NSString *fileContents=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&amp;error];
  NSLog(@"Prepostioned content length: %d",fileContents.length);
  //This outputs "Prepostioned content length: 0"
  
  //if file is present:
  if (!error) {
      //Do something
  
  }
  else
  {   
      //Print the error
      NSLog(@"Error : %@",error.description);
  }
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>Error Domain=NSCocoaErrorDomain Code=261 "The operation couldn’t be completed. (Cocoa error 261.)" UserInfo=0x8c410d0 {NSFilePath=/Users/ctb/Library/Application Support/iPhone Simulator/6.0/Applications/16881651-3790-4C87-A3A0-1E1D60563684/OAS IPAD.app/Object Bank/70118600.eam, NSStringEncoding=4}
  </code></pre>
  
  <p>The path does not return <code>nil</code> even when the file is not present and the <code>fileExistsAtPath:path</code> always returns yes irrespective of whether the file is present or not.</p>
  
  <p>I've tried this as well:</p>
  
  <pre><code>NSArray *paths =[[NSBundle mainBundle] pathsForResourcesOfType:@"eam" inDirectory:@"Object Bank"];
  for (NSString *path in paths) {
      NSString *fileString=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
      NSLog(@"Resource : %u ",fileString.length);
  }
  </code></pre>
  
  <p>But it has the same problem.</p>