Hi Vishal, Please refer the link below. Hope it helps..
http://blogs.technet.com/b/heyscriptingguy/archive/2008/05/02/how-can-i-identify-the-20-most-recently-modified-files-in-a-folder.aspx Regards *Shalabh Dixit*My QTP Blog <http://shalabhdixit.wordpress.com/> On Fri, Jun 5, 2015 at 4:24 PM, Vishal Gupta <[email protected]> wrote: > Guys any input for me > > > On Thu, Jun 4, 2015 at 11:14 PM, Vishal Gupta <[email protected]> > wrote: > >> Hello Friends >> >> I wrote a simple *.vbs function to get the file name of last two modified >> file and getting an error while retriving the value from the array. The >> error code is shared in the attached attachment and VB code is shared below: >> >> >> >> msgbox Isarray (GetFilename) >> >> msgbox UBound (GetFilename) >> >> msgbox LBound (GetFilename) >> >> abc = GetFilename(0) >> >> msgbox abc >> >> msgbox GetFilename(LBound (GetFilename)) >> >> msgbox GetFilename(UBound (GetFilename)) >> >> 'msgbox GetFilename(0) & "------------->" & GetFilename(1) >> >> >> Function GetFilename() >> >> >> Dim objShell >> Dim strPath >> Dim objFSO >> Dim objFile >> Dim GetCurrentFolderPath >> Dim objFolder >> Dim Flag >> Dim FileItem >> Dim Filename >> ReDim Filename(1) >> Dim Filename1 >> Dim File1 >> Dim Filename2 >> Dim File2 >> >> >> Set objShell = CreateObject("Wscript.Shell") >> strPath = Wscript.ScriptFullName >> >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> Set objFile = objFSO.GetFile(strPath) >> GetCurrentFolderPath = objFSO.GetParentFolderName(objFile) >> >> Set objFolder = objFSO.GetFolder(GetCurrentFolderPath) >> >> Flag = 1 >> >> For Each FileItem In objFolder.Files >> >> If FileItem.DateLastModified > File1 Then >> File1 = FileItem.DateLastModified >> Filename1 = FileItem.Name >> If Flag = 1 Then >> File2 = FileItem.DateLastModified >> Filename2 = FileItem.Name >> Flag = Flag + 1 >> End If >> End If >> >> If FileItem.DateLastModified > File2 And >> FileItem.DateLastModified < File1 Then >> File2 = FileItem.DateLastModified >> Filename2 = FileItem.Name >> End If >> >> >> Next >> >> Filename(LBound(Filename)) = Filename1 >> Filename(UBound(Filename)) = Filename2 >> >> >> GetFilename = Filename >> >> Set objFolder = Nothing >> Set objFile = Nothing >> Set objFSO = Nothing >> Set objShell = Nothing >> >> End Function >> >> >> -- >> Best regards, >> Vishal Gupta >> +919989475211 >> > > > > -- > Best regards, > Vishal Gupta > +919989475211 > > -- > -- > You received this message because you are subscribed to the Google > "QTP - HP Quick Test Professional - Automated Software Testing" > group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/MercuryQTP?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "QTP - HP Quick Test Professional - Automated Software Testing" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- You received this message because you are subscribed to the Google "QTP - HP Quick Test Professional - Automated Software Testing" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/MercuryQTP?hl=en --- You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
