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 8827757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:26:53+00:00 2026-06-14T07:26:53+00:00

The problem here is that I cannot appending a file name using stringByAppendingPathComponent fma

  • 0

The problem here is that I cannot appending a file name using “stringByAppendingPathComponent”
fma is a NSFileManager.

Working:

[fma changeCurrentDirectoryPath: [NSHomeDirectory() stringByAppendingPathComponent: @"Music/iTunes/iTunes Media/Music/ABC/DEF"]];
NSLog(@"Current Directory Path: %@", [fma currentDirectoryPath]); 

Output: Current Directory Path: /Users/plusa/Music/iTunes/iTunes Media/ABC/DEF

Not working:

[fma changeCurrentDirectoryPath: [NSHomeDirectory() stringByAppendingPathComponent: @"Music/iTunes/iTunes Media/Music/ABC/DEF/a.mp3"]];
NSLog(@"Current Directory Path: %@", [fma currentDirectoryPath]); // No change

Update

What I’m going to do is creating a simple fileManager.

main.m

#import <Foundation/Foundation.h>
#import "fileManager.h"

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        NSLog(@"Welcome to File Manager.");

        fileManager *fma = [[fileManager alloc] init];

        NSLog(@"Current Directory Path: %@", [fma currentDirectoryPath]);
        [fma changeCurrentDirectoryPath: [NSHomeDirectory() stringByAppendingPathComponent: @"Music/iTunes/iTunes Media/Music"]];
        NSLog(@"Directory Path changed to iTunes Music source base");

        [fma readCurrentItem];

    }
    return 0;
}

fileManager.h

#import <Foundation/Foundation.h>

@interface fileManager : NSFileManager {
    NSArray *list;
}

-(int) readCurrentItem;

@end

fileManager.m

#import "fileManager.h"

@implementation fileManager

-(int) readCurrentItem
{
    int i = 1;

    NSLog(@"Current Directory Path: %@", [self currentDirectoryPath]);
    NSLog(@"Reading Directory Path...");

    if(NSFileTypeDirectory == [[self attributesOfItemAtPath: [self currentDirectoryPath] error: nil] objectForKey: @"NSFileType"]) {
        list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[self currentDirectoryPath] error: nil];
    } else {
        NSLog(@"File");
        return 0;
    }

    i = 1;
    for (NSString *item in list)
        NSLog(@"Item #%i: %@", i++, item);


    NSLog(@"The item to read:");
    scanf("%i", &i);

    if (i == 0) {
        NSLog(@"Shutdown.");
        return 0;
    }

    [self changeCurrentDirectoryPath: [[self currentDirectoryPath] stringByAppendingPathComponent: [list[(i - 1)] lastPathComponent]]];

    [self readCurrentItem];

}

@end
  • 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-06-14T07:26:54+00:00Added an answer on June 14, 2026 at 7:26 am

    Because your second example refers to a file, not a directory.

    Presumably, the path is being composed correctly, but the NSFileManager is not changing the path to the file — again, because it is not a directory.

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

Sidebar

Related Questions

I have a problem here that still cannot solve, the thing is I have
I have a problem here that requires to design a data structure that takes
I built a linear layout inside of a dialog , the problem here that
My problem in here ( probably ) is that $db->fetch_array won't show all the
Updated Problem solved, I have some design problem here. The directory looks like that:
date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string
So here is the problem that I am facing: I have an application that
Here is a problem that has been bothering me a lot about Python, I
So here's my problem: I've created a custom AVCaptureSession that takes pictures. I'm not
Here is a JSFiddle that demonstrates the problem... http://jsfiddle.net/L2NBP/5/ For obvious reasons this code

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.