Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get only drive letters

Status
Not open for further replies.

lashwarj

IS-IT--Management
Nov 1, 2000
1,067
US
HOw do i instead of getting directorys , just get the drives
I have a tree listing app but need to have only drive letters for a porton of it. Below is my code

LOCAL drivesave
drivesave = GETDIR("C:\" ,"Select Only Drives", "Select Drive")
driveSAVE =ALLTRIM(driveSAVE)
ThisForm.driveletter.Value=SUBSTR(drivesave,1,LEN(DRIVESAVE))
THISFORM.Refresh
 
Nop enot what I am looking for, am looking for something like GETDIR() but that will only show drive letters. So when I select the drive I only get the C:\ listed not all the contents of the C:\
 
Another alternative is a Combobox with the RowSourcetype set to 7 - Files. The first entry will show the current drive and the sub menu off it will show all the available drives.

You could also load up your own listbox or combobox with a routine like (e.g. change the ? to Additem)
Code:
for lnii = asc('A') to asc('Z')
   lcDrive = chr(lnii)
   if BETWEEN(drivetype(lcDrive), 2, 6)
     ?	lcDrive+":"
   endif
endfor
See the help file for the Drivetype values in case you want to limit certain types of drives.

Rick
 
ok how do you do the second recomindation of yours
 
You can use the JUSTDRIVE() function:

cDrive = JUSTDRIVE("C:\TEMP\")
cDrive will contain "C:"

Use something like with JUSTDRIVE(GETDIR()) to get the user's selected drive.


Dave S.
 
Sorta but i am on a network and need to be able to select from about 13 different drives
 
JUSTDRIVE(GETDIR()) will work for network drives as well. Select the drive from the combo box.

Dave S.
 
ok but how do i set that up to work for me
 
do this at the foxpro command window
= dir2dbf(.t.,.t.,.t.)

this will create 3 VFP tables on the users hard drive
C:\FILES.DBF && a listing of all files in the default directory
C:\DIRECTRY.DBF && a lising of all sub-directories from the default directory
C:\DRIVES.DBF && a listing of all drive letters active on the computer.

= dir2dbf(.f.,.f.,.t.)
this will create a VFP table on the users hard drive
C:\DRIVES.DBF && a listing of all drive letters active on the computer.

use the dir2dbf command just before the call of the form or in the form's init area.
In your form when you make the popup menu from a database Use the C:\DRIVES.DBF and a list od the drive letters on the users computer appears.


David W. Grewe
Dave@internationalbid.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top