Micro Focus QTP (UFT) Forums
Write a program to print the current folder name in the local system. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Write a program to print the current folder name in the local system. (/Thread-Write-a-program-to-print-the-current-folder-name-in-the-local-system)



Write a program to print the current folder name in the local system. - kannan_panneerselvam - 05-15-2009

Hi can anyone answer my question quickly please.


Question:

Write a program to print the current folder name in the local system.


RE: Write a program to print the current folder name in the local system. - bfakruddin - 01-05-2010

Hi, It will give you the path of a folder

Code:
dim f,fso

set fso=createobject("scripting.filesystemobject")

set f=fso.getfolder("E:\Baba_QTP\QTP\Scripts")

msgbox f



RE: Write a program to print the current folder name in the local system. - sreekanth chilam - 01-05-2010

Hi Kannan,

In addition to Baba's solution, You can try in the below way for Printing the required FolderName in QuickTest Print Log.

Code:
Dim f,fso
set fso=createobject("scripting.filesystemobject")
set f=fso.getfolder("C:\Documents and Settings\csreekanth\Desktop\Srirama-ELC")
Print f.Name



RE: Write a program to print the current folder name in the local system. - azar80 - 01-05-2010

use inbuilt environment variable


RE: Write a program to print the current folder name in the local system. - bfakruddin - 01-06-2010

Hi,

Here is the code to get the only folder name not all the path of a folder.

Code:

Code:
dim f,fso

set fso=createobject("scripting.filesystemobject")

set f=fso.getfolder("E:\Baba_QTP\QTP\Scripts")

msgbox "Path of the Folder      :     "&f

ext=split(f,"\")

msgbox "Exact Folder Name    :   "&Exact

Function Exact()

for i=0 to ubound(ext)

Exact=ext(i)

Next

End Function



RE: Write a program to print the current folder name in the local system. - Saket - 01-07-2010

@D.Baba Fakruddin - The query was to get the current folder name which can be retrieved by environment variable suggested by azar80.
what you are doing is just parsing the path string which is required to be passed, right?


RE: Write a program to print the current folder name in the local system. - bfakruddin - 01-09-2010

Hello Saket,

Thanks for your advice. I think you do understand the question, Question is to write a script to get a Stored Folder Name. as per azar80 comments one line script. I don't think that is exact answer for this question. Any how, Ask for a question to Kannan_Paneersalvam once again and provide your valuable Answer. I am waiting for that.

I know only the above way to get a Folder Name. If you have any other way to get Folder Name other than above two ways. Please let me know.

Thanks & regards,
Baba Fakruddin.D


RE: Write a program to print the current folder name in the local system. - gowtham.m.h - 07-06-2011

I think this may help you

Code:
set WshShell = WScript.CreateObject("WScript.Shell")
Dir=WshShell.CurrentDirectory
arrydir=split(dir,"\")
msgbox arrydir(ubound(arrydir))

Thanks
Gowtham


RE: Write a program to print the current folder name in the local system. - souvikghosh_diatm - 07-09-2011

Well i have seen that commentators are arguing with their answer....actually the question is not clear.....

what exactly u want????

1. The current folder name only where you are present???
2. Or u need the full path of that folder where you are present???

The answer of 1st question is what exactly gowtham.m.h has suggested.....

and the answer of 2nd question is to use inbuilt Environment variable ("TestDir") what exactly azar80 has suggested.....

And i dont think bfakruddin has suggested any logical answer...he has just passed the string and printed that....but if i dnt know the string then what??? i guess exactly this thing is being asked in this question that how to get that string.......


So better try gowtham.m.h or azar80 suggestion as per ur need.....