Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get path to a directory
Message
 
 
To
12/12/2001 16:53:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00593473
Message ID:
00593816
Views:
27
This message has been marked as the solution to the initial question of the thread.
>The problem is though that I don't know if the directory 'progs' is a subdirectory of profiler or pro32. I do know that it is no more than 4 levels deep so I finally came up with the following:
>
>DO CASE
> CASE DIRECTORY(sys(2003)+'\'+'progs')
> thisform.pdir=FULLPATH(sys(2003)+'\'+'progs')
> CASE DIRECTORY(sys(2003)+'\'+'..\progs')
> thisform.pdir=FULLPATH(sys(2003)+'\'+'..\progs')
> CASE DIRECTORY(sys(2003)+'\'+'..\..\progs')
> thisform.pdir=FULLPATH(sys(2003)+'\'+'..\..\progs')
> CASE DIRECTORY(sys(2003)+'\'+'..\..\..\progs')
> thisform.pdir=FULLPATH(sys(2003)+'\'+'..\..\..\progs')
> OTHERWISE
> thisform.pdir=FULLPATH('progs')
>ENDCASE
>It's not pretty, but it works.
>Thanks all for your help!

Hi Tracy,

The following code should work with any level of subdirectories.
lcCurrPath = Fullpath("")
lcSubdir = "prgs"
lnCnt = 1
lcRelativePath = lcSubdir 

FOR lnLevel = Occurs("\", lcPath) TO 1 STEP  -1
	lcTestPath = Left(lcPath, Rat("\", lcPath, lnCnt))
	IF Directory(lcTestPath + lcSubDir)
		lcRelativePath = lcCurrPath + Replicate("..\", lnCnt-1) + lcSubdir 
		EXIT
	ENDIF
	
	lnCnt = lnCnt + 1
ENDFOR
? lcRelativePath 
? Fullpath(lcRelativePath )
Just remember that I did only limited testing.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform