ASP移动方法用于将指定的文件或文件夹移动到给定的目标。
用法:
对于文件对象:
FileObject.Move(destination)
对于文件夹对象:
FolderObject.Move(destination)
参数:该方法具有上面提到的和下面讨论的单个参数:
- destination:它指定文件或文件夹将被移动到的目的地。它不允许使用通配符。这是一个必需的参数。
下面的示例演示ASP移动方法。
范例1:下面的代码演示了ASP File.Move方法。
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
%>
输出:
Original File Content:This is an example file File is Moved! Moved File Content:This is an example file
范例2:下面的代码演示了ASP Folder.Move方法。
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
%>
输出:
Folder is Moved! Folder successfully accessed
相关用法
- p5.js Camera move()用法及代码示例
- ASP Flush用法及代码示例
- ASP End用法及代码示例
- ASP BinaryRead用法及代码示例
- ASP BinaryWrite用法及代码示例
- ASP Clear用法及代码示例
- ASP AppendToLog用法及代码示例
- ASP AddHeader用法及代码示例
- ASP Contents.Remove用法及代码示例
- ASP Server.MapPath用法及代码示例
- ASP Server.Execute用法及代码示例
- ASP Server.Transfer()用法及代码示例
- ASP Server.HTMLEncode()用法及代码示例
- ASP CreateFolder()用法及代码示例
- ASP BuildPath用法及代码示例
- ASP GetParentFolderName用法及代码示例
注:本文由纯净天空筛选整理自ManasChhabra2大神的英文原创作品 ASP Move() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。