Re: setFileNameAtPath ?
Re: setFileNameAtPath ?
- Subject: Re: setFileNameAtPath ?
- From: Chris Long <email@hidden>
- Date: Sun, 27 Jul 2003 12:57:07 +0900
Take a look at NSString documents under "working with paths"
stringByDeletingLastPathComponent
On Sunday, July 27, 2003, at 12:47 PM, R. Ecalcitrance wrote:
>
Friends,
>
>
a guy walks into a bar and says to the bartender:
>
>
"I have this code and it's working. but I'd like to change the
>
name of
>
the file at the end of the path. I've had a good poke round the apple
>
site
>
and through the ponderous list archive, nothing. seems like it should
>
be so
>
easy. am I just missing it?"
>
>
//
>
>
- (IBAction)push:(id)sender
>
{
>
int result;
>
>
NSArray *fileTypes =
>
[NSArray arrayWithObjects: @"aif",
>
NSFileTypeForHFSTypeCode('AIFF'),
>
@"sd2", NSFileTypeForHFSTypeCode('Sd2f'),
>
@"txt", NSFileTypeForHFSTypeCode('TEXT'),
>
nil];
>
>
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
>
[oPanel setAllowsMultipleSelection:NO];
>
>
NSString *username = NSUserName();
>
result = [oPanel
>
runModalForDirectory:NSHomeDirectoryForUser(username)
>
file:nil types:fileTypes];
>
>
if(result == NSOKButton)
>
{
>
int i = 0;
>
NSArray *filesToOpen = [oPanel filenames];
>
NSString *aFile_path = [filesToOpen objectAtIndex:i];
>
NSString *aFile = [[NSFileManager defaultManager]
>
displayNameAtPath:aFile_path];
>
>
[textField setStringValue:aFile];
>
}
>
}
>
>
//
>
>
>
Akira
>
>
>
>
>
>
__chaos_______to_
>
oO
>
http://AkiraRabelais.com
>
_______bliss__oO
>
>
chaos
>
chaps
>
chapt
>
coapt
>
coast
>
hoast
>
hoist
>
hoise
>
noise
>
noisy
>
noily
>
soily
>
saily
>
sadly
>
madly
>
sadly
>
sally
>
selly
>
sells
>
seals
>
sears
>
stars
>
stays
>
slays
>
slaps
>
slips
>
blips
>
bliss
>
_______________________________________________
>
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.
_______________________________________________
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.