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

  • Home
  • SEARCH
  • 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 8358647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:51:58+00:00 2026-06-09T10:51:58+00:00

I want to copy file from app NSBundle to Documents directory. How ever i

  • 0

I want to copy file from app NSBundle to Documents directory.

How ever i can’t get this code working:

-(NSString*)copyFile:(NSString*)name{


    NSString *storePath = [[[appDelegate applicationDocumentsDirectory] absoluteString] stringByAppendingPathComponent:name];

    NSError *error;

    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:storePath]) {
        NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"recordTest" ofType:@"caf"];
        if (defaultStorePath) {
            if ([fileManager fileExistsAtPath:defaultStorePath]) {
                [fileManager copyItemAtPath:defaultStorePath toPath:storePath error:&error];
                 NSLog(@"Error: %@)" , [error localizedDescription]);
            }


        }
    }
    return storePath;
}

This print The operation couldn’t be completed.

In more detail:

Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0xd629530 {NSUserStringVariant=(
    Copy
), NSFilePath=/var/mobile/Applications/D0183043-3FD2-4341-8DA4-E1D140E556F6/test.app/recordTest.caf, NSDestinationFilePath=file:/localhost/var/mobile/Applications/D0183043-3FD2-4641-8DA4-E5D140E556F6/Documents/recordTest.caf, NSUnderlyingError=0xd629970 "The operation couldn’t be completed. No such file or directory"}

I don’t get why there are No such file if i check before copying.

Any ideas ?

Thanks

  • 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-09T10:52:00+00:00Added an answer on June 9, 2026 at 10:52 am

    Your destination is a file URL, not a file path. I always use:

    NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
    NSString *documentFullPath = [documentsFolder stringByAppendingPathComponent:name];
    

    Or, in Swift 2:

    let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
    let fileURL = documents.URLByAppendingPathComponent(name)
    let documentsFullPath = fileURL.path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the %tagname% from a file and copy them to a
I want to copy war file to tomcat web-app directory using NSIS setup. I
My App has a database file in its NSBundle. I want to get update
i want copy pdf file from application path(/data/data/package name) to sdcard.for that i have
I want to copy a file from my one rails application to a remote/
I want to copy a xml file from one remote box to a bunch
I want to copy a .properties file from a certain location to my WEB-INF/classes/com/infiniti
I want grant user rights to copy a specific file from a remote server
I want to copy a selection of lines from a file to another file
I want to copy the newest file that is on a mapped network directory.

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.