How to find a latest file from any folder
Answer Posted / manjunathareddy
sPath="C:\FlightFrameWork"
Msgbox GetNewestFile(sPath)
Function GetNewestFile(ByVal sPath)
sNewestFile = Null
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
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
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How do you declare a variable in vbscript?
Both Static and dynamic arrays are handled by VB script. Is it true?
Mention what if you do not specify anything when you call a procedure?
Explain about arrays in vb script?
What are the valid scopes of a variable in vbscript?
what is the use of QCUtil? explain with one example?
Mention what is byref and byval parameters in vbscript?
What is event handling in vbscript?
PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com
What are keywords in the vbscript language?
How will you format a number in percetage format in vbscript?
How do i automate a website www.flyashx.com without having any test cases witin a week time.
What is the purpose of the err object in the vbscript language?
What is the difference between VBScript and JavaScript?
what types of bugs will we find out in banking projects for automation testing?