Reputation: 2543
I have a importFile stored at NSString* importFile (printed with NSLog %@):
/var/mobile/Applications/5CE1D252-E56A-4AAC-B88E-5B0CEFFF55B3/Library/Caches/tmp/temp_695D39E3-3359-415F-9C0D-243E2E117B8B-456-0000001384C17BBA.tmpfile
I then receive a destinationFile NSString * destinationFile a value of (printed with NSLog %@)
/var/mobile/Applications/5CE1D252-E56A-4AAC-B88E-5B0CEFFF55B3/Documents/Str%208829%20-%20Test.500887280
then I use NSFileManager to move the file:
NSFileManager* fileManager = [NSFileManager defaultManager];
assert(fileManager != nil);
NSError* error = nil;
[fileManager moveItemAtPath:importFile toPath:destinationFile error:&error];
the problem is that the actual file's name after the move is different from the requested destinationFile:
Str%25208829%2520-%2520Test.500887280
what's going on here ? what are those extra three 25 that seem to be the difference ?
Upvotes: 0
Views: 1411
Reputation: 3138
you have to define the file type and extension. Then you just have to move the file from one directory to another ... You can also rename the file
NSFileManager *manage = [NSFileManager defaultManager];
NSString *path = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/%@",Text.txt];
NSString *newPath = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/%@",newText.txt];
[manage moveItemAtPath:path toPath:newPath error:&error];
Upvotes: 1
Reputation: 6372
It looks like the %
in the filename is being encoded as %25
(the percent code for percent)
You might check this one out: URL-encoding and HTML-encoding NSStrings
Upvotes: 1