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
-2
votes
1 answer

Swift How to get the count of audio files in a folder inside the project manager

I have a BIG folder with dozens of folders inside, with a couple of audio files inside each folder. I need to get the count of audio files in every one of those sub folders (e.g. AppName/AudioFiles/ThirdFolder/(I need the count of all the audio…
-2
votes
1 answer

Incorrect method suggestion by Xcode

I am trying to create a directory in my OS X app. The method was suggested as I started typing. But the method seems to be incorrectly suggested. The attributes parameter of the method in NSFileManger normally takes a [FileAttributeKey:Any]…
Aravind G S
  • 392
  • 3
  • 17
-2
votes
2 answers

How to open local file in a view controller

I have an application which downloads file from the server. i want to open these files present in the file system in a new view controller. What can I do to open the files without using web view
Amon
  • 99
  • 1
  • 9
-2
votes
2 answers

Read/Write .string files from/to Directory

I have a framework that expects a .string file from the Project that it is imported to. How do I save a .string file from my app's [NSBundle mainBundle] to NSLibraryDirectory, and then have the framework read it from NSLibraryDirectory? Thank you
aalesano
  • 357
  • 2
  • 13
-2
votes
2 answers

UIImage saved to Document Directory returning nil

NSDocumentDirectoryI'm new to iOS. Im trying to build a simple app to better grasp Core Data and the file system. I can't retrieve data that I've apparently stored. -I check to see if the file exists at the path, which it does, but when I try to…
got2jam
  • 515
  • 5
  • 16
-2
votes
3 answers

How to filter array and let stay only strings end with .png

I am reading files from folder, folder contains .pngs but I get additionally Thumb.db file in every folder and all others are .pngs. I read content as NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path…
PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
-2
votes
1 answer

contentsOfDirectoryAtPath returning nil

I have a folder with a bunch of images named “Pictures” right inside “Supporting Files”, but when I try to retrieve the files it returns nil, even though I'm sure there are images inside; I try to do it with the following code inside…
-2
votes
1 answer

Could not create new directory in iOS 7

I am not able to create a new directory in my application's folder (iOS 7), Am using this code... NSFileManager *filemgr; NSArray *dirPaths; NSString *docsDir; NSString *newDir; filemgr =[NSFileManager defaultManager]; …
AC Mohan
  • 33
  • 1
  • 4
-3
votes
1 answer

Swift: Filemanager swap names of 2 files

I made "collectionView reorder by using drag feature". I drag file and need to change its name on the disk to make reorder. How can I swap file names for 2 files?
Haloo
  • 57
  • 5
-3
votes
1 answer

a warning about func unc createDirectoryAtURL(value of the type '()' )

I am learner on iOS Development,today i try to code somethingenter image description here about FileManger,but this method return a type '()',how can i to resolve it? the warning code as follow:
Jixes
  • 27
  • 6
-3
votes
3 answers

Create a Custom Formatted Dictionary Array from CSV File of Data

I've created an iPhone app that has a dictionary array of locations (lat,long,point). I created the array by manually entering each value. myLocationArray = @[ @{ kStation : @"1", kLatitude :…
JBeesky
  • 309
  • 2
  • 14
-3
votes
3 answers

ios - removing any file, but not all files from the Document Directory

I have this code, which allows me to specify a particular file to be deleted from my documents directory. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath =…
jwknz
  • 6,598
  • 16
  • 72
  • 115
-5
votes
1 answer

How to write at last index of file in write mode in iOS

I want to write data in file at the end of every call. How can I do this in iOS? Below are the steps. If "filename" doesn't exist create a new file And write NSData or Data content in the file. Next time when thread complete the work it will again…
Ajay_Kumar
  • 1,381
  • 10
  • 34
  • 62
1 2 3
96
97