用户登录
用户注册

分享至

VBS教程:方法-Copy 方法

  • 作者: 巧木露琪亚
  • 来源: 51数据库
  • 2021-08-08

copy 方法

将指定的文件或文件夹从某位置复制到另一位置。

object.copy destination[, overwrite]

参数

object

必选项。应为 filefolder 对象的名称。

destination

必选项。复制文件或文件夹的目标位置。不允许使用通配符。

overwrite

可选项。boolean 值。如果覆盖现有文件或文件夹,则 boolean 值为 true(默认);否则为 false

说明

对 file 或 folder 应用 copy 方法的结果与使用 filesystemobject.copyfile 或 filesystemobject.copyfolder 执行的操作完全相同。在 filesystemobject.copyfile 或 filesystemobject.copyfolder 中,使用 object 引用文件或文件夹,并将文件或文件夹作为参数传递给 filesystemobject.copyfile 或 filesystemobject.copyfolder。然而,应该注意的是 filesystemobject.copyfile 或 filesystemobject.copyfolder 方法可以复制多个文件或文件夹。

下列示例显示了 copy 方法的使用:

dim fso, myfileset fso = createobject("scripting.filesystemobject")set myfile = fso.createtextfile("c:\testfile.txt", true)myfile.writeline("这是一个测试")myfile.closeset myfile = fso.getfile("c:\testfile.txt")myfile.copy ("c:\windows\desktop\test2.txt")
软件
前端设计
程序设计
Java相关