简体   繁体   中英

Access file on mac share using NSFileManager

I need to access a shared file hosted on a mac shared folder, However when I directly pass the path to the NSFileManager it reports as file does not exist.

NSURL *fileURLPath = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@,%@",IP,PATH ]];

if ([[NSFileManager defaultManager] fileExistsAtPath:[fileURLPath path]])
{
}

I believe it's due to the authentication . How should handle or pass the credentials using the NSFileManager ?

It would be useful to see what your resulting URL looks like. If I understand your variable naming correctly, you're creating an invalid URL. If IP is @"127.0.0.1" and path is @"foo" , the resulting URL will be file://127.0.0.1,foo , which isn't a valid URL. NSFileManager expects a file URL pointing to a descendant directory of the mount point. This implies that the share has to be mounted. Authentication is not required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM