Re: Appending text to a file
Re: Appending text to a file
- Subject: Re: Appending text to a file
- From: Martin Weil <email@hidden>
- Date: Sun, 11 Aug 2002 22:07:07 +0200
Hi!
How can I append a string to a file ? I mean I don't want to overwrite
the
entire file, but just adding my text at its end.
Thanks
Nico
NSFileHandle *aFileHandle;
NSString *aFile;
aFile = [NSString stringWithString:@"Your File
Path"]; //setting the file to write to
aFile = [logFile stringByExpandingTildeInPath];
aFileHandle = [NSFileHandle
fileHandleForWritingAtPath:aFile]; //telling aFilehandle
what file write to
[aFileHandle truncateFileAtOffset:[aFileHandle
seekToEndOfFile]]; //setting aFileHandle to write at the end of
the file
[aFileHandle write
Data:[toBeWritten
dataUsingEncoding:nil]]; //actually write the data
For more Information see Documentation---Foundation---NSFileHandle
Hope this helps!
Regards,
Martin
--
http://www.mweil.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.