Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving a fiel from one location to another
#1
Solved: 10 Years, 9 Months, 3 Weeks ago
Hi,
I need to move a file from one location to another
the below mentioned is the script
:
Move a file from one location to another.




-----------------------------------------------
Code:
'function: FileMove
'desc :    Moves a file from one location to another
' params :  strFile - full path to the source file
'           strTarget - the folder to move the file to
' returns : void
' ------------------------------------
Function FileMove(strFile, strTarget)

Dim objFS

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

' check that the source file exists
If Not objFS.FileExists(strFile) Then

    ' fail if the source does not exist
    reporter.ReportEvent micFail, "Move File", "Unable to Move the File '"& strFile &"', It Does Not Exist"

Else

    ' create the destination folder if it doesn't already exist
    If Not objFS.FolderExists(strTarget) Then

        objFS.CreateFolder(strTarget)

    End If
    
    ' move the file
    objFS.MoveFile strFile, strTarget

End If

' destroy the object
Set objFS = Nothing

End Function 'FileMove

Here where i need to mention the Source fiel and target file
Source file :a
Target file :b
Reply


Messages In This Thread
Moving a fiel from one location to another - by siri - 08-05-2008, 01:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to paste file location in QTP camillelola 0 1,351 08-09-2018, 10:54 AM
Last Post: camillelola
  Selecting file saved in a location excellentpawan 1 3,856 02-25-2014, 02:05 PM
Last Post: guin.anirban
  Copy file to network shared location sams001 0 2,972 04-03-2013, 02:10 AM
Last Post: sams001
MyBB Saving an excel file with the same name and same location after updating few columns pKrishna 1 4,750 01-04-2013, 04:40 PM
Last Post: Ankesh
  Moving QTP scripts from QC to a desktop PC adityasrinivasb 1 3,099 08-02-2011, 06:07 PM
Last Post: uma87

Forum Jump:


Users browsing this thread: 1 Guest(s)