windows volume name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dmorley123
Forum Newbie
Posts: 2
Joined: Tue May 30, 2006 1:31 pm

windows volume name

Post by dmorley123 »

I want to open a file in a volume whose name I know, but whose drive letter I don't know.

How can I associate a volume name with its drive letter (in windows)?

Thanks.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Where do you want to get the file from?
dmorley123
Forum Newbie
Posts: 2
Joined: Tue May 30, 2006 1:31 pm

volume name

Post by dmorley123 »

I have a USB stick with volume label MyUSB. I don't know in advance the drive letter which will assigned to the stick when I plug it in. But I do know the label name (MyUSB). To open a file on that stick I need the drive letter. e.g. fopen("F:myfile.txt,"r"). How can I open the file knowing only the label of the drive?

I've devised a hack which loops through all the drive letters and calls exec("vol <drive letter>:", $volInfo) and looking for the label in $volInfo. There's gotta be a better way. (For one thing, I get 26 Dos windows popping up, one for each drive letter!).

Thanks.
Post Reply