title: Why can't I save files to my iOS apps /Documents directory?
body: <p>I am writing an app that can access the iOS root system, the user should be able to save files to his document directory. I am using this code to save the file to the document directory.</p>
  
  <p>For Text: </p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                                   NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  [self.filePath writeToFile:[NSString stringWithFormat:@"%@/%@", documentsDirectory, [self.filePath lastPathComponent]]
                                             atomically:YES
                                               encoding:NSUTF8StringEncoding error:nil];
  </code></pre>
  
  <p>For other files: </p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                                   NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  [self.filePath writeToFile:[NSString stringWithFormat:@"%@/%@", documentsDirectory,[self.filePath lastPathComponent]]
                                             atomically:YES];
  </code></pre>
  
  <p>My problem is I can save .txt files, but not other files, If I save for example .plist files with the  save text methods, the contact is replaced by the directory path of the file. When I save a picture, or any other file it isn't readable. Is there a good method to save files without destroying them?</p>