• 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: Zero kb file copied
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zero kb file copied


  • Subject: Re: Zero kb file copied
  • From: Lorenzo <email@hidden>
  • Date: Fri, 23 Dec 2005 13:53:09 +0100

Hi,
I think you made some confusion at defining the paths.
If you want to copy a file to the folder containing the executable, that is
the folder "Contents/MacOS/", you should do:

NSString *fileName = @"myFile.txt";
NSString *sourcePath = [[NSHomeDirectory()
stringByAppendingPathComponent:@"Desktop"]
stringByAppendingPathComponent:fileName];
NSString *destPath = [[[[NSBundle mainBundle] executablePath]
stringByDeletingLastPathComponent]
stringByAppendingPathComponent:fileName];

BOOL copied;
copied = [manager copyPath:sourcePath toPath:destPath handler:nil];
// to check the task
NSLog(@"sourcePath %@", sourcePath);
NSLog(@"destPath %@", destPath);
NSLog(@"copied %d", copied);

Here this worked. Also, check that the source file is really bigger than
zero bytes at the moment of the copy.
Anyway you should know that on some machine, the current user could not have
the permissions to write within that folder, so the copy will fail.
If you need to store some preferences or template to a file, you should copy
the file within the (Home)/Library/Preferences folder or to
(Home)/Library/Application Support



Best Regards
--
Lorenzo
email: email@hidden

> From: email@hidden
> Reply-To: email@hidden
> Date: Thu, 22 Dec 2005 23:46:14 -0800 (PST)
> To: email@hidden
> Subject: Cocoa-dev Digest, Vol 2, Issue 1790
>
> Message: 2
> Date: Fri, 23 Dec 2005 01:59:33 +0100
> From: St?phane Sudre <email@hidden>
> Subject: Re: Zero kb file copied
> To: Sanri Parov <email@hidden>
> Cc: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>
> On jeudi, décembre 22, 2005, at 10:01 PM, Sanri Parov wrote:
>
>> Hi everybody,
>>
>> I'm having a little trouble in copying a file from the desktop to the
>> application bundle using NSFileManager.
>> When it comes to copy the file, it turns out the copied file is in the
>> right location I choose but it's zero KB in size.
>> Here's a little snippet:
>>
>> NSString *stringaDiControllo = [NSString stringWithString:[[[NSBundle
>> mainBundle] executablePath] stringByAppendingString:@"/"]];
>> boolValue=[fm copyPath:[sheet filename] toPath:stringaDiControllo
>> handler:nil];
>>
>> boolValue returns TRUE, which means the file is copied, but I can't
>> understand why it's empty...
>> Any clues?
>
> Does this happen in special conditions? Such as you're copying the file
> to a network volume.
>

_______________________________________________
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

  • Prev by Date: NSURLReqest and cookies
  • Next by Date: Splash Screen Creation
  • Previous by thread: Re: Zero kb file copied
  • Next by thread: Core Data: Master-Detail question
  • Index(es):
    • Date
    • Thread