set fso=server.CreateObject("scripting.filesystemobject")
oldfile="1.txt"
newfile="2.txt"
if fso.fileExists(server.mappath(oldfile)) then fso.movefile server.mappath(oldfile) server.mappath(newfile)
通过脚本语句三(下面是一个ASP对文件改名的例子)。
Set fso = Server.CreateObject("Scripting.FileSystemObject")
mapnewurl=新文件路径和文件名
mapurl=旧文件路径和旧件名
mapfile=server.mappath(""&mapurl&"")
mapnewfile=server.mappath(""&mapnewurl&"")
If fso.FileExists(mapfile) Then
fso.MoveFile mapfile, mapnewfile
end if