rustylepord
rustylepord

Reputation: 5801

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 ?

Upvotes: 1

Views: 435

Answers (1)

gcbrueckmann
gcbrueckmann

Reputation: 2453

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.

Upvotes: 1

Related Questions