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 to Import data from a file (file is on the desktop) to the data table
How will you get the last occurrence of one string within another string using vbscript?
How can you destroy an object in vbscript?
Mention what is the main difference between function and sub-procedure?
How will you release the memory acquired by an array variable in vbscript?
How to get the length of the string by making use of the string function?
how to answer "TELL ME ABOUT UR SELF" as exp.person. whr to start and whr to stop. can anyone tel me
What is Procedure or Subroutine in VB Script?
how to increasing the numbers in a given text box please write a vb script
Explain the constants in vbscript?
How do you declare a variable in vbscript?
Write a vbscript procedure that converts feet to inches. Hint: there are 12 inches in a foot?
Explain the string concatenation function in vbscript?
Dear All, I am geting below IE error whilie executing the QTP scripts in Batch mode "Internet Explorer has encountered a problem and needs to close. We are sorry for the inconvenience." can any one suggest me how to resolve this issue . Thanks Balaji
write a function to read the items from combobox of Flight reservation & save in excel (QTP)??