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
Is vbscript language a case-sensitive language and what does it mean?
What is the difference between javascript and vbscript?
How should i Create Email invite with server-side Coding?
Both Static and dynamic arrays are handled by VB script. Is it true?
Which object is used to work with the excel sheets in the vbscript language and what statement is used to create this object?
What is the output of a + b in vbscript if a = 5 and b = 10?
Explain the string concatenation function in vbscript?
Which in-built function related to an array joins substrings into one string in the vbscript language?
PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com
after medical test,when will be the police verification
If a calulator having 3 buttons (of any number)in 3 of them one is not working properly due to which answer is wrong always. write a script to find out which button is not working properly ?
Explain a few date functions in vbscript
How to Import data from a file (file is on the desktop) to the data table
How to make professional test report using vbscript code in UFT, which gives us complete analysis of the test.
create a form to accept username and password validate the username and password with using message box, display the corresponding user message