ASP Move() Method
The ASP Move Method is used to move the specified file or folder to the given destination.
Syntax:
For File object:
FileObject.Move(destination)
For Folder object:
FolderObject.Move(destination)
Parameters: This method has a single parameter as mentioned above and discussed below:
- destination: It specifies the destination where the file or folder would be moved to. It does not allow wildcard characters. This is a required parameter.
The below examples demonstrate the ASP Move Method.
Example 1: The below code demonstrates the ASP File.Move Method.
ASP
<%dim fs,f,tsset fs=Server.CreateObject("Scripting.FileSystemObject") 'Getting the file to be copiedset f=fs.GetFile("d:\GFG.txt") 'Reading the contents of the fileset ts=f.OpenAsTextStream(1)Response.Write("Original File Content: " & ts.ReadAll)ts.Close 'Moving the file to the given pathf.Move("d:\newfolder\GFG.txt") Response.write("<br>" & "File is Moved!" & "<br>") 'Getting the moved fileset f=fs.GetFile("d:\newfolder\GFG.txt") 'Reading the contents of the moved fileset ts=f.OpenAsTextStream(1)Response.Write("Moved File Content: " & ts.ReadAll)ts.Close set f=nothingset fs=nothing%> |
Output:
Original File Content: This is an example file File is Moved! Moved File Content: This is an example file
Example 2: The below code demonstrates the ASP Folder.Move Method.
ASP
<%dim fs,f,tsset fs=Server.CreateObject("Scripting.FileSystemObject") 'Getting the folder to be copiedset f=fs.GetFolder("d:\GFG") 'Moving the folder to the given pathf.Move("d:\newfolder\GFG") Response.write("Folder is Moved!") 'Getting the moved folderset f=fs.GetFolder("d:\newfolder\GFG") Response.write("<br>" & "Folder successfully accessed") set f=nothingset fs=nothing%> |
Output:
Folder is Moved! Folder successfully accessed

