• 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
Re: Moving Files From /private/tmp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving Files From /private/tmp


  • Subject: Re: Moving Files From /private/tmp
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 30 Mar 2005 03:25:05 +0200

Oliver,

On 29.3.2005, at 23:28, Oliver Cameron wrote:

I'm having some trouble using the NSFileManager method movePath:toPath:handler. Basically, what I want to do is place a png file inside a folder I create in /private/tmp, then later retrieve this file and overwrite a file with the same filename somewhere in the Users folder. This is my code to do this:

NSString *privateString = @"/private/tmp/My Folder/";
NSString *privateFullString = [privateString stringByAppendingPathComponent:[file lastPathComponent]];
[[NSFileManager defaultManager] movePath:privateFullString toPath:[NSHomeDirectory() stringByAppendingPathComponent:@"FolderWhereFileWithSameFileNameIs"] handler:nil];


When I NSLog(privateFullString), I get the correct file path. And I checked /private/tmp and my file is correctly getting added to it, but when I try and move it (via the code above), nothing happens.

First, as somebody else already pointed out, make sure the target file does not exist yet.


After that, beware, this is no "cp" :) You have to specify both file names, no default "if target is a folder use the source" in this case applies. Trherefore, you'll need something like

[[NSFileManager defaultManager] movePath:privateFullString toPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"FolderWhereFileWithSameFileNameIs"] stringByAppendingPathComponent:[file lastPathComponent]] handler:nil];

---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc

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


References: 
 >Moving Files From /private/tmp (From: Oliver Cameron <email@hidden>)

  • Prev by Date: Re: Recommended Reading
  • Next by Date: validateMenuItem isn't called?
  • Previous by thread: Re: Moving Files From /private/tmp
  • Next by thread: Re: Moving Files From /private/tmp
  • Index(es):
    • Date
    • Thread