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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to choose a drive 2

Status
Not open for further replies.

aliane

Programmer
Mar 20, 2002
6
DZ
Hi
please tell me how to choose a drive for saving some files
thinks
 
Hi Aliane.

Do you have a group of files that you want to copy elsewhere? If this is the case, you can use GETDIR() to select the destination folder and then use the COPY FILE command to copy your files to that folder. Both of these commands are well documented in the on-line help.



Marcia G. Akins
 
Thanks for yours replies
but I want like
GETFILE(),GETDIR()... GETDRIVE() (for example)
I want GETDRIVE() making me choosing between ( A: C: D: E: G: ...)
 
Aliane;

I am not aware of a VFP native function to return a list of disk drives.
Use the following program to give you a list of drives in an array which you can use to populate a listbox or whatever you need.

Hope this helps;
Ed


Code:
DECLARE INTEGER GetLogicalDrives IN kernel32
DIMENSION aDrives(26) && Drive letters found will be stored in this array

GetDrives()

? "Available disk drives:"
FOR nCnt = 1 TO ALEN(aDrives)
	? aDrives(nCnt)
ENDFOR
RETURN
*!*
FUNCTION GetDrives
*!*	The GetLogicalDrives function retrieves a bitmask 
*!*	representing the currently available disk drives
*!*
*!*	The return value is a bitmask 
*!*	representing the currently available disk drives. 
*!*	Bit position 0 (the least-significant bit) is drive A, 
*!*	bit position 1 is drive B, bit position 2 is drive C, 
*!*	and so on

LOCAL nDrivesMask, nIndex, nShift, nAIdx
nDrivesMask = GetLogicalDrives()
nIndex = 0
nAIdx = 0
DO WHILE .T.
	nShift = BITLSHIFT(1, nIndex)
	IF BITAND(nDrivesMask, nShift) = nShift
		nAIdx = nAIdx + 1
		aDrives(nAIdx) = CHR(nIndex + 65)
	ENDIF
	IF nShift > nDrivesMask
		EXIT
	ENDIF
	nIndex = nIndex + 1
ENDDO

DIMENSION aDrives(nAIdx)	&&Redimension array to the number of drives we found
RETURN



Please let me know if the suggestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
faq184-4449 Enumerate Available Shares and Current Mapping has a few gems too.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top