Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading folder
#6
Solved: 11 Years, 4 Months ago
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-H...t=function

Code:
Function GetNewestFile(ByVal sPath)

   sNewestFile = Null   ' init value

   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oFolder = oFSO.GetFolder(sPath)
   Set oFiles = oFolder.Files

   ' enumerate the files in the folder, finding the newest file
   For Each oFile In oFiles
     On Error Resume Next
     If IsNull(sNewestFile) Then
       sNewestFile = oFile.Path
       dPrevDate = oFile.DateLastModified
     Elseif dPrevDate < oFile.DateLastModified Then
       sNewestFile = oFile.Path
     End If
     On Error Goto 0
   Next

   If IsNull(sNewestFile) Then sNewestFile = ""

   GetNewestFile = sNewestFile

End Function
sPath = "c:\my test"  'Here my test is the folder name
Set oFSO = CreateObject("Scripting.FileSystemObject")
sNewestFile = GetNewestFile(sPath)
If sNewestFile <> "" Then
   WScript.Echo "Newest file is " & sNewestFile
Else
   WScript.Echo "Directory is empty"
End If
Reply


Messages In This Thread
reading folder - by jove1776 - 08-25-2010, 07:14 PM
RE: reading folder - by supputuri - 08-25-2010, 07:45 PM
RE: reading folder - by iamsekhar - 08-30-2010, 02:33 PM
RE: reading folder - by jove1776 - 08-25-2010, 08:18 PM
RE: reading folder - by supputuri - 08-25-2010, 09:34 PM
RE: reading folder - by jove1776 - 08-26-2010, 01:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Global Sheet's DataTable Value Bhuvana 0 1,640 01-05-2020, 10:03 PM
Last Post: Bhuvana
  Executing via create "RES"xx folder? nishitd 0 1,254 03-07-2018, 01:09 AM
Last Post: nishitd
  Reading Value from Java Table arjun.singh 8 24,412 10-11-2017, 02:51 PM
Last Post: sivaji
  Reading data from excel sheet serenediva 1 9,622 03-03-2017, 10:07 AM
Last Post: vinod123
  code for validation to create a sub folder smiley 0 1,548 10-19-2016, 10:08 PM
Last Post: smiley

Forum Jump:


Users browsing this thread: 3 Guest(s)