Search code examples
objective-cfilecopying

Copy a file from /file to /folder/file


I have been working on an app for a while now, and it is supposed to copy files. I have the code:

- (IBAction)moveFile:(id)sender
{
  NSFileManager *filemgr;
  filemgr = [NSFileManager defaultManager];
  NSString *fileToMove = [NSString stringWithFormat:@"%@", "TestText.txt"];
  if ([filemgr copyItemAtPath: fileToMove toPath: @"./Test/File.txt" error: NULL]  == YES) {
    NSLog (@"Copy successful");
  } else {
    NSLog (@"Copy failed");
  }
}

As you can see, it is supposed to copy the file TestText.txt to the folder /Test/ and rename it File.txt When I activate it, the button clicks, and nothing happens.

Can anyone tell me how to make it work?

Thanks!


Solution

  • I fixed it. Did some code-crunching, think it was the "./....." part.