views:

128

answers:

2

Hi. 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!

+2  A: 

You have forgotten a @ before "TestText.txt".

neoneye
Sigh, it is still not working neoneye.Not trying to beg, but is there anything else?
HiGuy Smith
A: 

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

HiGuy Smith