Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get path to a directory
Message
 
 
À
12/12/2001 16:53:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00593473
Message ID:
00593816
Vues:
28
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform