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

displaying a selected icon from a nstableview in an imageviewer

I have a tableview that acts like an upload menu. It contains 4 columns : icon , name, size and date. Data are displayed in the nstablevier from an array controller (there is no IBOutlet tableview declared, and i don't use datasource). I have an…
Wael
  • 71
  • 5
0
votes
1 answer

Tutorials For using NSFileManager to store data?

Hi I am looking for some tutorials on using NSFileManager to store data in the directories such as cache and such, I havent really been able to find a good one with any nice examples. Any recommendations on where to find some? Thanks. ps. I know…
Terrel Gibson
  • 481
  • 1
  • 6
  • 21
0
votes
1 answer

displaying data in nstableview from a directory

I want to display fileNames , types , size ... in a table view. I've tried to display the file names.the table view is filled by data but they are not displayed. A warning is shown : 'directoryContectsAtPath:' is deprecated. Here is the code (.m…
Wael
  • 71
  • 5
0
votes
1 answer

copyItemAtPath:toPath:error: is returning NO

The chapter I'm reading is talking about NSFileManager, and the author said to create an empty file called testFile. The testFile is under the same folder as main.m. I didn't create newfile. I'm not able to copy testFile, and it's returning 2 and a…
Emily
  • 9
  • 2
0
votes
2 answers

What is the correct way to save user data using NSFileManager?

I am having trouble initializing dictionaries I use throughout my program to store user achievements and scores. I have almost identical code for the two dictionaries and only the gameCenterData dictionary seems to be working properly. I have tried…
Nairb555
  • 3
  • 2
0
votes
2 answers

Cpanel File manager Extract button disable

Today i found extraction of zip file seems disabled in cpanel File Manager.Yesterday it was working fine and i had extracted one file .I had uploaded a big file of size 472MB.but then uploading got cancelled and From then I am facing the…
user1071339
0
votes
2 answers

How to read .docx file & show its contents in UITextView?

I have tried with this: BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, …
Surjit Joshi
  • 3,287
  • 2
  • 18
  • 20
0
votes
1 answer

Is there any memory limitation for saving .mp3 data to iOS device using iOS application

I am developing an application, that has a module downloading MP3 files from a server and save the last 5 downloads to iOS device. For this I am using NSFileManager and document directory (each downloads has 40MB to 60MB). Now I am facing some…
John
  • 734
  • 3
  • 14
  • 30
0
votes
4 answers

Download file to Folder in iPhone

I am new to iPhone, I made app in which, when user downloads anything it gets downloaded into DocumentDirectory I wants downloading inside my folder which i have created in DocumentDirectory How to achieve this ? I thought I will download file to…
Krunal
  • 6,440
  • 21
  • 91
  • 155
0
votes
1 answer

Path of Trash in attributesOfItemAtPath:

I am creating a cocoa app which will give the size of the Trash in MB,GB,etc. So far I have got the code to find the size of an item at a given path: unsigned long long fileSize = [[[NSFileManager defaultManager]…
user1445205
0
votes
3 answers

NSFileManager works fine on simulator but not on device

I have problem creating directories and files with NSFileManager on the iPhone device. My code, shown below, works fine on the simulator, but not on the device, could you please help me? Gimme some directions where the problem may be, thanks for…
Jenicek
0
votes
1 answer

Storing files on simulator vs actual iOS device

Currently I am storing some mp3 files locally on a simulator using the following code to obtain a path.. manager = [NSFileManager defaultManager]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); …
Joel
  • 4,732
  • 9
  • 39
  • 54
0
votes
1 answer

iPhone App no longer has write permissions

I have an app that needs to be able to write to the /var/mobile/Applications/.../Documents directory. This was working fine, but for some reason now when I run my code NSFileManager createFileAtPath returns NO every time. I have no idea why this…
Robin
  • 737
  • 2
  • 10
  • 23
0
votes
1 answer

Objective-C passing NSError pointer to NSFileManager within custom method

I have a method that uses ARC and takes an NSError pointer and I pass that into the contentsOfDirectoryAtPath:error: method of NSFileManager like so: + (NSArray *) getContentsOfCurrentDirectoryWithError: (NSError **)error { // code here …
Thick_propheT
  • 1,003
  • 2
  • 10
  • 29
0
votes
1 answer

Objective-C, NSTask won't touch files

I have the following code (below) in my app, which simply tries to use NSTask to touch one file with the directory time/date stamp. It works just fine in an app which only accesses one directory all the time, however, it doesn't with another that…
Joe Habadas
  • 628
  • 8
  • 21