|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
How To Determine Current Directory DepthAll examples below with with this code. The approach does not work with relative paths. iLevel = ParseCount(Trim$(mypath$,"\"),"\")
mypath$ = "c:\two\three\"
mypath$ = "c:\two\three"
mypath$ = "\two\three\"
mypath$ = "\two\three"
mypath$ = "\\SERVER1\Employees\Bob\"
mypath$ = "\\SERVER1\Employees\Bob" Source: http://www.powerbasic.com/support/pbforums/showthread.php?p=351474#post351474
|
|
|
|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
The following code allows relative paths too... #COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL MyPath AS STRING
LOCAL iLevel AS INTEGER
MyPath = ".\Examples\Code\Folder1\Folder2"
REPLACE ".\" WITH "" IN MyPath
REPLACE "\\" WITH "" IN MyPath
iLevel = PARSECOUNT(TRIM$(mypath$,"\"),"\")
MSGBOX STR$(iLevel)
END FUNCTION
|
|
|
|
|