Open In App

ASP Move() Method

The ASP Move Method is used to move the specified file or folder to the given destination.

Syntax:



Parameters: This method has a single parameter as mentioned above and discussed below:

The below examples demonstrate the ASP Move Method.

Example 1: The below code demonstrates the ASP File.Move Method.




<%
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.




<%
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

Article Tags :