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

Get FolderPath

Status
Not open for further replies.

Xsi

Programmer
May 29, 2015
121
0
0
SE
Hello everyone,

I have got following folder structure:

FuncLib
ObjReb
Temp
TestData
TestSuite


I am using QTP/UFT Test-automation its (vb.net)


with following command I get current folderpath:
Code:
 TestPath =Environment("TestDir")]

result:
C:\XXX_xxxxx_xxxx-xx-xx\TestSuite\Maincase


now I need to get to the root folder in

C:\XXX_xxxxx_xxxx-xx-xx
since all the folders have different length of the name I found it little bit difficult.



I am not able to use len / left.

I tried with mid and instrrev
Code:
Environment.value("TestPath") =Mid(TestPath,1,Instrrev(Mid(TestPath,1,instrrev(TestPath,"\")-1),"\"))

then I get following result:
C:\XXX_xxxxx_xxxx-xx-xx\TestSuite\Maincase

regardless how many -1 I put nothing changes.

Could someone help me out?

Thank you in advance
 
I tested your code and it works, returns C:\XXX_xxxxx_xxxx-xx-xx\ for me.

I see you are getting the path from Environment("[highlight #FCE94F]TestDir[/highlight]") and saving it to a different variable Environment("[highlight #FCE94F]TestPath[/highlight]"), not sure if this is the problem.
 
Three functions I wrote for my now abandoned ASP CMS·

Code:
 vBScript]
public function GetPath(FldrCount)
dim ThisPage
ThisPage = Split(Request.ServerVariables("PATH_INFO"), "/")
if FldrCount > ubound(ThisPage) then
else
GetPath = ThisPage(ubound(ThisPage)- FldrCount)
end if
end function

function GetFolders(ByVal p_iFldrCount)
dim ThisPage
ThisPage = Split(Request.ServerVariables("PATH_INFO"), "/")
if p_iFldrCount > ubound(ThisPage) then
else
GetFolders = ThisPage(ubound(ThisPage)- p_iFldrCount)
end if
end function

function GetRootPath()
GetRootPath = replace(lcase(request.servervariables("PATH_TRANSLATED")),lcase(GetPath(0)),"")
end function

GetRootPath() may do what you need.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top