title: how to copy file from main bundle to Document Folder
body: <p>I want to check one file in Document folder.I want if this file not exist in document folder copy it from main bundle to document folder. I write this code and this file to be copy but my problem here.....!!!! my file is .sqlite file (Database file) and when copy to document folder hasn't data in self!!!! why??? while the this file when is in main bundle has data in self.</p>
  
  <p>this is my code but I don't know why not work!!!!</p>
  
  <pre><code>#define DataName @"mydatabase.sqlite"
  
  
  - (void)viewDidLoad
  {
      [self CopyDatabase];
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  }
  
  - (NSString*)DatabasePath
  {
      NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *DocumentDir = [Paths objectAtIndex:0];
      //NSLog(@"%@",DocumentDir);
      return [DocumentDir stringByAppendingPathComponent:DataName];
  
  }
  
  - (void)CopyDatabase
  {
      BOOL success;
      NSFileManager *fileManager = [NSFileManager defaultManager];
      success = [fileManager fileExistsAtPath:[self DatabasePath]];
      NSString *FileDB = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:DataName];
      if (success)
      {
          NSLog(@"File Exist");
          return;
      }
      else
      {
          [fileManager copyItemAtPath:FileDB toPath:[self DatabasePath] error:nil];
      }
  
  }
  </code></pre>