Questions tagged [nsfilemanager]

The NSFileManager class enables you to perform various generic file-system operations and insulates an application from the underlying file system.

An apple class reference.

A simple file handling

//Gives you document folder detail

    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager setDelegate:self];
    NSError *error;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSArray *newfilelist=[fileManager contentsOfDirectoryAtPath:documentsDirectory error:&error ];

//gives your file is file or directory

NSString *path = @"/Users";
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSLog(@"fileManager=%@", fileManager);
    BOOL bDirectory;
    BOOL bExists = [fileManager fileExistsAtPath:path isDirectory:&bDirectory];
    NSLog(@"%@: bExists=%d bDirectory=%d", path, bExists, bDirectory);
1453 questions
-1
votes
1 answer

Saved PDF to Disk; won't Load in WebView Offline

I can't wrap my head around the issue here: I save a PDF to disk - then load I try to load the PDF on a physical device and turn on airplane mode. File doesn't load. Can you help me ? It's clearly an issue of saving to and retrieving from the same…
soulshined
  • 9,612
  • 5
  • 44
  • 79
-1
votes
2 answers

Copy files 10.10 Yosemite

I have project with MAgicalRecords and OSX it is convertor SQLITe -> coreData . Before Yosemite - it worked well but after update - have some troubles My Steps [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) { …
-1
votes
2 answers

NSURL path not working, but NSString path working

I saved an object to file and I am now trying to run a check on whether or not that file exists. I have confirmed the path of the file and concluded that the IF statement works when I hard code the path as a NSString, see first block. However, when…
giuseppe
  • 17
  • 4
-1
votes
1 answer

iOS NSFileManager - delete file from main app bundle

In my app people can download some audio-lessons from my server. After a file is saved i move it to app's document directory. Now i want my app to have the first file downloaded with the app, so user have one lesson out of the box. I've added that…
serg_ov
  • 563
  • 7
  • 18
-1
votes
1 answer

Saving images from an array to a file in filemanager

I have been working with nsfilemanager and trying to save images as files where the images are obtained from an array. But i couldn't find a solution.
user3815344
  • 243
  • 1
  • 21
-1
votes
2 answers

Convert NSData to NSString and convert again to NSData?

I have this code who get a file inside my iOS, convert it to an NSData and converts it into a NSString: NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; NSData *files = [filemgr contentsAtPath:databasePath]; NSData *databuffer =…
user3781174
  • 245
  • 5
  • 16
-1
votes
1 answer

PDF file size from document directory showing zero in iOS

I am retrieving file size of PDF file that located in document directory with following codes. - (NSString *)sizeOfFile:(NSString *)filePath { NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath…
Fire Fist
  • 7,032
  • 12
  • 63
  • 109
-1
votes
1 answer

Using Car2go Api for iOS app

Hi I am trying to get the list of all car2go cars and use it for a test application, the only problem is I do not know how to get the information. I have gotten a consumer key and secret key but the problem is I am unsure how to get the file using…
user2076774
  • 405
  • 1
  • 8
  • 21
-1
votes
3 answers

return all file names inside a folder in IOS app

How can i read all files list or array inside a directory. This directory/folder is inside my IOS app I check the below code but it returning me null. NSError *error; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString…
user2706827
  • 195
  • 2
  • 11
-1
votes
1 answer

NSFileManager: not working properly

I am using below code to save and read saved clicked image file from document directory. Its working well for the first time but when i'm trying to read the saved image file for the second time, its showing me the image clicked during first time. -…
Varun Mehta
  • 1,733
  • 3
  • 18
  • 39
-1
votes
1 answer

Loading image from folder using NSBundle and plist

Trying to Display the load the image from the folder present on MAC desktop using path like (/Users/sai/Desktop/images/aaa.jpg) Which is created in plist file called Data.plist at item0. As im using NSBundle it is diaplying the image path but not…
lreddy
  • 449
  • 6
  • 19
-1
votes
1 answer

Can't Create a new file using NSData writeFile, NSFileManager and NSURL never returns the filePath

am working over an iOS App and am having a huge bad time over this issue, here is the thing: 1.- Am creating a file based on some NSData 2.- Am trying to retrieve the NSURL of that new file that i just created the issue is that the NSURL doesn't…
-1
votes
2 answers

Can i make a html file in Documents directory which accesses jquery and cordova in the app bundle?

I am building a html file which is stored in [[PROJ UserDirectory] stringByAppendingPathComponent:@"tmp_Form_File.html"] and inside of the file "tmp_FOrm_File.html" it is being dynamically built. Body shows up correctly but the JS will not…
Fallenreaper
  • 10,222
  • 12
  • 66
  • 129
-1
votes
1 answer

display file properties in nstableview

I want to display files' data in a tableview . Files are stored in a directory. I want to display in the tableview : the icon , name , size and the date of the files. Thanks to NSFileManger , I found how to display directory's content ,but I can't…
Wael
  • 71
  • 5
-2
votes
2 answers

Deleting/Overwriting Image files on iphone obj c

I am attempting to delete or overwrite an image within a specific directory. I grab all my images in an array and place in a table view. When an image is clicked photo roll is opened and the user chooses an image. when the imagepicker controller is…
FreeAppl3
  • 858
  • 1
  • 15
  • 32
1 2 3
96
97