Quick test professional

QTP Tips QTP codes QTP Faqs and more

Get The Latest Created File

   Const cdtFirst = #1/1/100#

   Dim sFolder  : sFolder    = “.\”
   Dim oFS      : Set oFS    = CreateObject( “Scripting.FileSystemObject” )
   Dim dtLatest : dtLatest   = cdtFirst
   Dim sExt     : sExt       = “ppt” ‘ not entirely sure about this extension
   Dim oLFile   : Set oLFile = Nothing
   Dim oFile
   For Each oFile in oFS.GetFolder( sFolder ).Files
       If sExt = LCase( oFS.GetExtensionName( oFile.Name ) ) Then
          If dtLatest < oFile.DateLastAccessed Then ‘ maybe DateCreated/DateLastModified
             dtLatest = oFile.DateLastAccessed
             Set oLFile = oFile
          End If
       End If
   Next
   If oLFile Is Nothing Then
      WScript.Echo “No file with extension”, sExt, “found.”
   Else
      WScript.Echo “found”, oLFile.Name, oLFile.DateLastAccessed
   End If

Advertisements

February 15, 2008 - Posted by | Files and Folders | , , , , , , , , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: