hi all, am programing a simple app, i wanted to read the content of a file uisng the code:
the error i get is : Error Domain=NSCocoaErrorDomain Code=260 "The file “sample.txt” couldn’t be opened because there is no such file."
now am sure that the file is there.
plz help
Code:
NSFileManager *filemgr;
NSString *currentPath;
filemgr =[NSFileManager defaultManager];
currentPath = [filemgr currentDirectoryPath];
NSString *name = [currentPath stringByAppendingPathComponent:@"sample.txt"];
NSError *error = nil;
NSString* content = [NSString stringWithContentsOfFile:name
encoding:NSUTF8StringEncoding
error:&error];
if(error) { // If error object was instantiated, handle it.
NSLog(@"ERROR while loading from file: %@", error);
// …
}
NSLog(@"%@",content);
the error i get is : Error Domain=NSCocoaErrorDomain Code=260 "The file “sample.txt” couldn’t be opened because there is no such file."
now am sure that the file is there.
plz help
Last edited by a moderator: