I want to move 2 files with NSFileManager
, but it isn't moving my files:
at myfolder
There are 5 text file, that i will remove all this files
My code:
BOOL isDir;
if([[NSFileManager defaultManager] fileExistsAtPath:@"/volume/netrt/myfolder/" isDirectory:&isDir]) {
[[NSFileManager defaultManager] removeItemAtPath:@"/volume/netrt/myfolder/*" error:nil]; // for delete all files
[[NSFileManager defaultManager] movItemAtPath:@"/rdns/macross/text1.txt" toPath:@"/volume/netrt/myfolder/" error:nil];
[[NSFileManager defaultManager] movItemAtPath:@"/rdns/macross/text2.txt" toPath:@"/volume/netrt/myfolder/" error:nil];
}
The folder myfolder
already exists. What is my mistake?
thank you so much
There's very likely other issues going on, but for starters, the
toPath:
needs an actual file name.[[NSFileManager defaultManager] movItemAtPath:@"/rdns/macross/text1.txt" toPath:@"/volume/netrt/myfolder/text1.txt" error:nil];
Add "text1.txt" to the end of your
toPath:
.NSFileManager documentation