• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with NSFileManager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with NSFileManager


  • Subject: Problem with NSFileManager
  • From: "K. Chen" <email@hidden>
  • Date: Wed, 2 Sep 2009 11:50:40 -0700

I ran into a weird situation with NSFileMnager. 

First my code want to see if a file already exists

if (![fileManager fileExistsAtPath:myConfigFile]) 

the result is NO, so my code goes into the if block


Then my code tries to copy the file over from the bundle; note the the destination is under <app_home>/Documents.

if (![fileManager copyItemAtPath:configFilePath toPath:myConfigDir error:&err])  

Here I got the error message from [NSError localizedDescription] saying: Operation could not be completed. File exists. 

Well first FM told me the file doesn't exist and then when I tried to copy, it said it already exists???

I suspect the file was in a weird state so I tested with another function and got some extra info.

if (![fileManager removeItemAtPath: myConfigFile error:&err])  

Here it got another error: Operation could not be completed. (Cocoa error 4)


Any help will be appreciated.


-KC


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem with NSFileManager
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Xcode 3.2 fails to highlight errors in Java source
  • Next by Date: Re: recompile without -mlong-branch?
  • Previous by thread: Re: Xcode 3.2 fails to highlight errors in Java source
  • Next by thread: Re: Problem with NSFileManager
  • Index(es):
    • Date
    • Thread