Ramesh,
Try with this. This will solve your issue.
' ########################################################
Option Explicit
Dim fso, path, file, recentDate, recentFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set recentFile = Nothing
'**** To retrieve the recent modified file in the folder *********
For Each file in fso.GetFolder("D:\Practice\Demo").Files
If (recentFile is Nothing) Then
Set recentFile = file
ElseIf (file.DateLastModified > recentFile.DateLastModified) Then
Set recentFile = file
End If
Next
'**** If the file is recent modified one then it is being copied to another
folder *********
If recentFile is Nothing Then
msgbox "No recent file(s)."
Else
msgbox "Recent file is : " & recentFile.path & " and Modified Time : " &
recentFile.DateLastModified
If fso.FileExists(recentFile) Then
msgbox recentFile.path
fso.copyfile recentFile.path, "D:\Practice\", True
End If
End If
' ########################################################
Regards,
Anil Rai
On Saturday, June 7, 2014 7:03:46 PM UTC+5:30, Rames kumar wrote:
>
> Hi
> I need help in Copying a file(name changes dynamically) from one location
> into another location
>
> Dim FSO
> Set FSO = CreateObject("Scripting.FileSystemObject")
> FSO.CopyFile "C:\filename.zip","d:\Testfolder\"
> Set FSO=nothing
>
> I use the above code for copying a file form one location to another. Now
> I have a situation where the file name changes each time. Suggest me a
> logic.
> Thanks in advance.
> Rames kumar
>
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.