Issue
I want to move a png file from user's Mac desktop to a mounted Windows file share. I can't seem to be able to make the remote path work with the code I'm using.
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr copyItemAtPath: stringFilePath toPath: @"/NameOfFileShare/Path/To/Folder/FileName.png" error: NULL] == YES)
NSLog (@"Copy successful");
else
NSLog (@"Copy failed");
I've tried many variations of the remote file path. I can use the code above successfully if paths are local. How can I move a file to a remote share???
Solution
Mac OS (OS X) loads the network drivers under /Volumes
alongside other drivers. Therefore your code should look something like this:
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr copyItemAtPath: stringFilePath toPath: @"/Volumes/NameOfFileShare/Path/To/Folder/FileName.png" error: NULL] == YES)
NSLog (@"Copy successful");
else
NSLog (@"Copy failed");
Pay attention to the path that starts with /Volumes
It should work now.
Answered By - Rojan Gh.