title: Unable to copy file from bundle to Documents directory, why does fileExistsAtPath return error?
body: <p>I'm using the following snippet of code to attempt to copy a file from my application resources directory into the Documents area. I have used the below from the <a href="https://github.com/rcarlsen/Pocket-OCR" rel="nofollow noreferrer">PocketOCR</a> project on Github :</p>
  
  <pre><code>// Set up the tessdata path. This is included in the application bundle
      // but is copied to the Documents directory on the first run.
      NSString *dataPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"tessdata"];
      NSFileManager *fileManager = [NSFileManager defaultManager];
  
      NSLog(@"Datapath is %@", dataPath);
      // If the expected store doesn't exist, copy the default store.
      if (![fileManager fileExistsAtPath:dataPath ]) {
          NSLog(@"File didn't exist at datapath...");
          // get the path to the app bundle (with the tessdata dir)
          NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
          NSString *tessdataPath = [bundlePath stringByAppendingPathComponent:@"tessdata"];
          if (tessdataPath) {
              [fileManager copyItemAtPath:tessdataPath toPath:dataPath error:NULL];
          }
      }
  </code></pre>
  
  <p>This is the output I get from invoking the above :</p>
  
  <blockquote>
    <p>2012-06-06 14:53:42.607 MyApp[1072:707] Datapath is
    /var/mobile/Applications/9676D920-D6D1-4F86-9177-07CC3247A124/Documents/tessdata
    Error opening data file
    /var/mobile/Applications/9676D920-D6D1-4F86-9177-07CC3247A124/Documents/tessdata/eng.traineddata</p>
  </blockquote>
  
  <p>I have the eng.traineddata file located in my xcode project like so </p>
  
  <p>It appears that the Error is being reported when attempting to check if <code>fileExistsAtPath</code>, I wouldn't expect this to throw an error, but to either return YES or NO.</p>
  
  <p>Is there an easier way to copy the <code>eng.traineddata</code> file across, or have I made a mistake which can be corrected here?</p>
  
  <p><img src="https://i.stack.imgur.com/SMXiP.png" alt="I have the eng.traineddata file located in my xcode project like so"></p>