How to find a file on iPad?

2.7k views Asked by At

I am supposed to have downloaded a file on the iPad simulator, using an appication.

How can I check that this file is present on the iPad simulator file system ?

Is there some file manager that I can use to check the existence of the file and possibly its contents?

2

There are 2 answers

5
Krumelur On

You can find the simulator at

/Username/Library/Application Support/iPhone Simulator/4.2/

where "4.2" is the SDK version. Under that folder you find all applications in cryptical subfolders. One of them is yours. In there you'lss find "Documents" which is your app's personal folder.

0
Jamie Chapman On

Use these methods, you can verify a file is present in the documents directory. I've not tested this exact example but it should work.

Example:

NSString *filePath = [self dataFilePathInDocuments:@"MyFile.txt"];
if([self fileExistsAtPath:filePath]) {
    NSLog(@"The file exits at %@", filePath);
} else {
    NSLog(@"The doesn't exist at %@", filePath);
}

Code:

- (NSString *)dataFilePathInDocuments:(NSString*)aFilename {
    NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDirectory = [paths objectAtIndex:0];

    return [docDirectory stringByAppendingPathComponent:aFilename];
}

- (BOOL) fileExistsAtPath:(NSString*)aFilepath {
    NSFileManager *fm = [NSFileManager defaultManager];
    return [fm fileExistsAtPath:aFilepath];
}