Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:31:00+00:00 2026-05-27T06:31:00+00:00

I was wondering how to read a file from a specific location on ios.

  • 0

I was wondering how to read a file from a specific location on ios.

For example I’d quite like to have files of the same name stored in different locations for example.

Project/Files/Text/1.txt

Project/Files/MoreText/1.txt

At the moment I can load files in but I can’t see how to specify a specific directory. My program seems to load a file in regardless of where it is meaning I can only have one text file or the other working.

I have tried using NSFileManager:

NSFileManager *filemanager = [NSFileManager defaultManager];

NSArray *filelist = [filemanager directoryContentsAtPath:@"Text"];

but I later realised that this actually isn’t doing anything. It just returns no objects. I’ve also seen NSBundle but haven’t seen an example where a specific file is returned.

I need the filenames to be the same for my algorithm which loads the files.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:31:01+00:00Added an answer on May 27, 2026 at 6:31 am

    If you want to read files from the app bundle and you want a certain directory structure, then you need to create a directory in Finder. Then create the directory structure you want in the main directory you just made. Now add the files to the appropriate folders and then add the main directory to your project by dragging it in to Xcode.

    Here is the code to read from the main bundle:

        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Text/1" ofType:@"txt"];
        NSString *testString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
        NSLog(@"%@",testString); 
    

    This will read the file “1.txt” from the directory “Text”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just wondering how I can read a text file in php, I'd like
I have got this read file code from microsoft @C:\Users\computing\Documents\mikec\assignment2\task_2.txt That works fine when
I was wondering if anyone knows how to open and read from a file
I was wondering, is it possible to read/write a file from/to a certain user
I was wondering if it was possible to read a text file that was
I need to read in a rolling log file in .NET 3.5sp1. I'm wondering
I was wondering if i could safely read from an XmlDocument object using SelectNodes()
I am trying to read an XSLT file from disk in my ASP.Net MVC
I have a couple of JMS file stores from a Weblogic 10.3 server, and
Hey I'm trying to open a file and read just from an offset for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.