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

HOW TO CHECK IF A DIRECTORY EXISTS

Status
Not open for further replies.

Maricus

Programmer
Mar 9, 2001
41
KE
Hello guys,

1. Is there a way, using Foxpro 2.6a DOS, to check if a directory type by a user exists/is valid?

2. It is possible to know the DEFAULT directory. However, how can I check and return the current directory.


Regards.
Maricus.
 
To get the default directory, there are a couple of options>

SYS(5) returns default drive letter.
SYS(2003) returns default directory.
Also CURDIR() returns current directory.

So to get default directory type either
a) SYS(5)+SYS(2003) OR
b) SYS(5)+CURDIR()

As for checking if a directory exists, the easiest way is
to use the GETDIR() function which displays a directory dialogue for selection.

Say mydir = getdir()
Choose directory from dialogue and mydir will hold selected value.

HTH.
 
Maricus,
This is a routine that I've used:

*!*****************************************
*!
*! Function: ISDIR
*!
*!*****************************************
*PROCEDURE isdir
PARAMETERS pcDirectory && Directory to check
LOCAL lcCurDir, ;
llError, ;
lcOnError
lcCurDir=SYS(5)+CURDIR()
llError=.F.
lcOnError=ON("ERROR")
ON ERROR llError=.T.
SET DEFAULT TO (ALLTRIM(pcDirectory))
SET DEFAULT TO (lcCurDir)
ON ERROR &lcOnError
IF EMPTY(pcDirectory)
llError = .T.
ENDIF
RETURN NOT llError

Rick

 
note on al's post, i use the getdir() funtion in a lot of programs and have found that until your users get used to its appearence they get VERY confused.
 
Sorry if you did not understand me properly.

My reasons for the request:

I want to write an instal program that prompts a users to enter a directory (using fox26DOS).
- I want to check if the directory exist.

- Also, once the installation is complete, I want to write an option that'll check for the DIR where the main .exe file is. The procedure should then return this DIR. How Guys?

Maricus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top