Re: Path to desktop
Re: Path to desktop
- Subject: Re: Path to desktop
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 9 Jul 2007 10:37:47 -0700
On 7/9/07, Micha Fuhrmann <email@hidden> wrote:
Do I really need to reconstruct the full path with
stringByAppendingPathComponent ?
There's got to be something simple!!!
Any help very much appreciated.
Try the following (note -[NSString stringByExpandingTildeInPath] and
-[NSString fileSystemRepresentation], the later should be used when
passing a path to a POSIX API, etc.)...
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSArray* paths;
paths = NSSearchPathForDirectoriesInDomains( NSDesktopDirectory,
NSUserDomainMask, NO );
NSString* fullPathToDesktop = [[paths objectAtIndex:0]
stringByExpandingTildeInPath];
const char* fullPathToDesktopFS = [fullPathToDesktop
fileSystemRepresentation];
NSLog(@"NSDesktopDirectory:\n %@ [%s]", fullPathToDesktop,
fullPathToDesktopFS);
[pool release];
return 0;
}
On 7/9/07, Jim Turner <email@hidden> wrote:
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"];
That should do what you need.
You really should use NSSearchPathForDirectoriesInDomains or "drop"
down to FSFindFolder.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden