Re: How to get hard drive name
Re: How to get hard drive name
- Subject: Re: How to get hard drive name
- From: Lorenzo <email@hidden>
- Date: Tue, 20 Jan 2004 21:32:08 +0100
Hi, welcome.
Also, I made a mistake when I made the sample of a file on your boot disk
theFile = @"/MyBootDisk/MyFolder/MyFile";
it should be written
theFile = @"/MyFolder/MyFile";
Anyway this doens't change anything in the code.
Best Regards
--
Lorenzo
email: email@hidden
>
From: "Ian G. Gillespie" <email@hidden>
>
Date: Tue, 20 Jan 2004 12:25:34 -0800
>
To: Lorenzo <email@hidden>
>
Subject: Re: How to get hard drive name
>
>
Thank you!
>
>
On Jan 20, 2004, at 12:21 PM, Lorenzo wrote:
>
>
> Hi,
>
> given a file "theFile"
>
>
>
> NSString *theFile = @"/Volumes/MyDisk/MyFolder/MyFile";
>
> NSString *diskName;
>
> NSFileManager *manager = [NSFileManager defaultManager];
>
>
>
> you can get the volume name this way:
>
>
>
> // this will give you an array of path components you can use
>
> // to display the path to the user in the MacOS 9 style.
>
> pathDisplayArray = [manager componentsToDisplayForPath:theFile];
>
>
>
> // the first item of the array contains the disk name @"MyDisk"
>
> // so take it from the array with the index = 0;
>
> if(pathDisplayArray && [pathDisplayArray count] > 0){
>
> diskName = [pathDisplayArray objectAtIndex:0];
>
> }
>
>
>
> // if theFile is on your boot disk like this
>
> theFile = @"/MyBootDisk/MyFolder/MyFile";
>
> // you will get diskName = @"MyBootDisk";
>
>
>
>
>
> Best Regards
>
> --
>
> Lorenzo
>
> email: email@hidden
>
>
>
>>
>
>> Message: 14
>
>> To: email@hidden
>
>> From: "Ian G. Gillespie" <email@hidden>
>
>> Subject: How to get hard drive name
>
>> Date: Tue, 20 Jan 2004 11:30:21 -0800
>
>>
>
>> Greetings,
>
>>
>
>> Does anyone know how I can get the name of a user's hard drive, or the
>
>> hard drive partition on which their user account resides?
>
>>
>
>> ~Ian
_______________________________________________
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.