nsfilemanager

Is it possible to search files of particular extension in the entire device ?

In my application, i am trying to find all files of particular extension (like .pdf, .txt, etc) that are stored in the device (either downloaded or transferred from system) and want to list them in table View. Is it possible to do so and if it is then can i associate file of specific extension to get it open in supporting application (an...

Check if file on website exists

Hi, on the iPhone I want to check, if a specific file (test.licence) on a website exsists. My approach (so far) was to download the file and check if it exists in my Documents directory. However, if the file does not exists, Apache presents a HTML error page (which I download instead of test.licence). Checking the file size is a fuzzy s...

iphone charset howto

Hi all, i've a class (downloaded from internet) that read a value of a file in this way (and after split the file): NSArray* array = [fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; where fileContents is my fullpathoffile. in which way i must write my string? i'm trying with thi...

Cocoa Touch: How can I access resource sub-directory?

Currently I am working on iPad. In the Resources folder of project, I have a sub-directory "sounds". How can I access it to get the contents of this sub-directory? I have tried: NSArray *array = [fileManager directoryContentsAtPath: [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"soun...

NSFileProtectionComplete for iOS 4.0 apps

I saw a WWDC 2010 video about NSFileProtectionComplete and protecting app's data. Are there any examples out there? Does any one have sample code to share? ...

iPhone (iOS): copying files from main bundle to documents folder causes crash

Hi, I am trying to set up my application so that on first launch, a series of files located in the "Populator" folder in the main bundle are copied into the documents directory. My current implementation is as follows: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSS...

iPhone (iOS): copying files from main bundle to documents folder error

Hi, I am trying to copy some files across from my app bundle to the documents directory on first launch. I have the checks in place for first launch, but they're not included in code snippet for clarity. The problem is that I am copying to the documents directory (which already exists) and in the documentation, it states that: dstP...

In objective-c on iPhone, I am attempting to use the NSFileManager. I can't figure out what directory it starts out in.

My question is, what directory does the NSFileManager start out in, I am really confused because when I run code to tell me what directory I'm in, it just outputs /. Also I can change directory to /private/var but not into /mobile and /mobile/applications which is where the application is. Bellow is my code. NSString *currentpath; fil...

iPhone : Unable to copy from MainBundle to NSDocumentDirectory

Hi, I am trying to copy a couple of image files from my MainBundle/SampleImages folder to the application NSDocumentDirectory/Library folder, but am unable to do so. I have checked that the images are in .app/Mainbundle/SampleImages directory and I have also checked that the Library folder is being created in the NSDocumentsDirectory, ...

Array of NSStrings from filenames within a folder?

I'm trying to create an array of NSStrings of the contents of a folder that I've dragged into my project... but when I count the items in the array afterwards, it's always comes back with 0; So, my folder in my project looks like this -Cards -Colors Blue.png Green.png Orange.png Yellow.png Purple.png Bla...

NSFileManager creating folder (Cocoa error 513.)

Hello everyone, I'm trying to create a folder inside the /sounds folder of my app. -(void)productPurchased:(UAProduct*) product { NSLog(@"[StoreFrontDelegate] Purchased: %@ -- %@", product.productIdentifier, product.title); NSFileManager *manager = [NSFileManager defaultManager]; NSString *bundleRoot = [[NSBundle mainBundl...

How to rename File using NSfilemanager

HEllo, I have a only a single file by name of a.caf in documents diretory . I want to rename it when user taps into textbox annd press change (the text entered into textbox should be the new filename). How is it possible ? Thanks in advance . Thanks, Mindfreak ...

iphone NSFilemanager not creating file

I'm using NSFileManager to create a file at a specified path with text view contents. I'm using following code [[NSFileManager defaultManager] createFileAtPath:saveFileName contents:[[tView text] dataUsingEncoding:NSASCIIStringEncoding] attributes:nil]; But the problem is that, its creating file with no contents. I'm sure that text co...

NSFileManager fileExistsAtPath: & symbolic links

In my ~/Library/Caches/ directory, I have a symbolic link to my app's bundle, and some symbolic links to images (e.g. "big_picture.png" is a symlink to "small_picture.png"). When I try to check if the symlinks exist, using the NSFileManager's fileExistsAtPath: method, it returns NO, even when the symlink does exist, and it links to a fil...

removeitematpath question...

Hello, I got this app that needs to be updated with a new database. I want to remove the old one and replace it with the new. This is the code I'm using: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSString...

removeItemAtPath dosn't work on the device

Hi all. I'v been struggling with this one for some time so any hint or suggestion are welcome. I'm trying to delete a file from a directory under "Documents". The problem is that the file is not delete on the device dow it is on the simulator. Just to add to the mystery, before the call to removeItemAtPath I check if the file exists wi...

Automatically observing filesystem changes in UITableView

Hello, I'm hoping someone could suggest a way that I could automatically "observe" changes in a filesystem with a UITableView. I have a UITableView populated with the contents of files in my directory. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [path...

NSFileManager in document folder

hi there, i am trying to zip a file into a subfolder in my iphone app. NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *dir = [path objectAtIndex:0]; NSString *storeunzipfiles = [dir stringByAppendingPathComponent:@"/MyFolder"]; if (![[NSFileManager defaultMa...

Strange bug when renaming a file with NSFileManager

I used to use the following to rename aplist file with various user inputted values (BOOL,Strings mostly): [manager moveItemAtPath:oldPath toPath:newPath error:&error]; And for some reason in iOS4+ this glitches out, so I Attempt the following: [1] [manager copyItemAtPath:oldPath toPath:newPath error:&error]; [2] [manager rem...

NSFilemanager one directory back ?

Hello , i want to know if there is a way to get the previous directory when working with NSFileManager... This can be probably done by appending '..' to the current directory ([[NSFileManager defaultManager] currentDirectoryPath] ) , but it's not a good idea at all :( Is there another effective way to do this ? ...