reading folder - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: reading folder (/Thread-reading-folder) |
reading folder - jove1776 - 08-25-2010 Hi there, I have a situation where I have to create a specific file and put it into a folder. I need to get the file name from this file and then use this file name to search on a webtable after it has been uploaded into my application I am testing. I created scripts for the creating the file and searching the webtable for the value My idea is to place this file into a folder and have QTP read the name of this file and pass that value to the function that searches the webtable. How do I achieve the part that reads the folder for the file name? I cant hardcode the filename as I never know what it will be... Thanks! RE: reading folder - supputuri - 08-25-2010 Hi Jove, You can develop a recursive function to go through the folders and pickup the absolute path to the desired folder and then you can pass that to you function. Please let me know if you need help in developing the recursive function. Let me know if you have any more questions or need more info. RE: reading folder - jove1776 - 08-25-2010 As there will only ever be one file in the folder this is what i did, guess i could drop the for loop from this example. Code: Dim oFolder, sOut, oFSO, callnr thanks! RE: reading folder - supputuri - 08-25-2010 Hi, Are the folder name and path or static or dynamic. If they are static then you can go-a-head with the code that you have developed (But Validate the File Name, then only exit the loop :-)), else you have to go with the recursive function. RE: reading folder - jove1776 - 08-26-2010 Hi Supputuri, thanks for your help. The folder location is static and I planned to have only one file in there at one time. You see the file contains a number of tab seperated text blocks one entry is a callid - which i need to search for in the system once this file has been uploaded. I am searching on a specific screens webtable. To make life easier i just named the file by this callid. It kind of restricts me to just having one file in the folder at any one time, which cant be good. Do you have any other suggestions? I know that the call id is 10 characters into the text file and the callnr is 9 characters long. How do I read this from the file? Even though what I did above will do for the short term, do you have any other suggestions to my problem? RE: reading folder - iamsekhar - 08-30-2010 Hi, I have posted some time back related to this kind of query but not exactly same. I hope it will helps you below code. Dont follow exact code. I just gave for your reference for reading file from folder. For details refer below link: https://www.learnqtp.com/forums/Thread-How-to-get-row-count-if-xls-file-is-generating-dynamically?highlight=function Code: Function GetNewestFile(ByVal sPath) |