Dim a1,a2,a3,a4,a5,a6
Set a1=createobject("scripting.filesystemobject")
Set a2=a1.createfolder("e:\han")
Set a3=a1.createtextfile("e:\han\8.txt")
Set a6=a1.getfolder("e:\han")
Set a4=a1.getfile("e:\han\8.txt")
Set a5=a1.opentextfile("e:\bin.txt",2,true)
a5.writeline("the last modified time is '"&a4.datelastmodified&"'")
a5.close
If a4.datelastmodified="2007-8-13" Then
a4.delete
else
a4.copy("e:\8.txt")
a6.delete
End If
执行到a6.delete那句的时候总是提示没有权限,谁知道为什么吗
原帖由 vincenthan 于 2007-8-14 10:32 发表
Dim a1,a2,a3,a4,a5,a6
Set a1=createobject("scripting.filesystemobject")
Set a2=a1.createfolder("e:\han")
Set a3=a1.createtextfile("e:\han\8.txt")
Set a6=a1.getfolder("e:\han")
Set a4=a1.getf ...
因为你在脚本的第3、4两行分别把文件夹han和文件8.txt赋给了对象变量a2和a3,在删除语句之前没有释放这些对象。
你可以不必赋值给a2和a3,写成:
Set a1=...
a1.createfolder("e:\han")
a1.createtextfile("e:\han\8.txt")
... ...
或者,在a6.delete之前把a2,a3释放掉:
... ...
Set a2 = Nothing
Set a3 = Nothing
a6.delete
... ...
Dim a1,a2,a3,a4,a5,a6
Set a1=createobject("scripting.filesystemobject")
Set a2=a1.createfolder("e:\han")
Set a3=a1.createtextfile("e:\han\8.txt")
Set a2=a1.getfolder("e:\han")
Set a3=a1.getfile("e:\han\8.txt")
Set a4=a1.opentextfile("e:\bin.txt",2,true)
a4.writeline("the last modified time is '"&a3.datelastmodified&"'")
a4.close
If a3.datelastmodified="2007-8-13" Then
a3.delete
else
a3.copy("e:\8.txt")
a2.delete
End If