在asp中如何用fso实现文件的建立,删除和重命名????

来源:百度知道 编辑:UC知道 时间:2024/05/17 23:38:17

'建立文件
filename = year(date()) & month(date()) & day(date()) & hour(time()) & minute(time()) & second(time()) & ".txt"
Set fso = Server.createobject("scripting.filesystemobject")
thepath = Server.mappath(filename)
Set thefile = fso.createTextfile(thepath)
thefile.writeline "新建立文件"
thefile.close
Set fso = Nothing

'删除文件
Sub DelFile(filename)
Dim fo,filenamestr
Set fo = Server.Createobject("Scripting.FileSystemObject")
filenamestr = Server.MapPath(filename)
If fo.FileExists(filenamestr) Then fo.DeleteFile filenamestr
Set fo = Nothing
End Sub

重命名
<%
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile server.mappath("tupian.jpg"),server.mappath("图片.jpg")
Set fso=Nothing
%>

方法二:
<%
Dim fso,f
Set fso = Cre