Open In App
Related Articles

ASP Move() Method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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,ts
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Getting the file to be copied
set f=fs.GetFile("d:\GFG.txt")
  
'Reading the contents of the file
set ts=f.OpenAsTextStream(1)
Response.Write("Original File Content: " & ts.ReadAll)
ts.Close
  
'Moving the file to the given path
f.Move("d:\newfolder\GFG.txt")
  
Response.write("<br>" & "File is Moved!" & "<br>")
  
'Getting the moved file
set f=fs.GetFile("d:\newfolder\GFG.txt")
  
'Reading the contents of the moved file
set ts=f.OpenAsTextStream(1)
Response.Write("Moved File Content: " & ts.ReadAll)
ts.Close
  
set f=nothing
set 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,ts
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Getting the folder to be copied
set f=fs.GetFolder("d:\GFG")
  
'Moving the folder to the given path
f.Move("d:\newfolder\GFG")
  
Response.write("Folder is Moved!")
  
'Getting the moved folder
set f=fs.GetFolder("d:\newfolder\GFG")
  
Response.write("<br>" & "Folder successfully accessed")
  
set f=nothing
set fs=nothing
%>

                    

Output:

Folder is Moved!
Folder successfully accessed


Last Updated : 24 Mar, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads