足球游戏_中国足彩网¥体育资讯$

vbs复制文件夹的实现代码
来源:易贤网 阅读:675 次 日期:2016-06-16 10:55:34
温馨提示:易贤网小编为您整理了“vbs复制文件夹的实现代码”,方便广大网友查阅!

代码如下:

dim fso, copycount

set fso = createobject(scripting.filesystemobject)

copycount = copycount + xcopy(fso, .\1, .\2, true)

msgbox 拷贝了 & copycount & 个文件!

'********************************************************************

'* function : xcopy

'*

'* purpose: 复制文件和目录树。

'*

'* input: fso filesystemobject 对象实例

'* source 指定要复制的文件。

'* destination 指定新文件的位置和/或名称。

'* overwrite 是否覆盖已存在文件。 ture 覆盖, false 跳过

'*

'* output: 返回复制的文件个数

'*

'********************************************************************

function xcopy(fso, source, destination, overwrite)

dim s, d, f, l, copycount

set s = fso.getfolder(source)

if not fso.folderexists(destination) then

fso.createfolder destination

end if

set d = fso.getfolder(destination)

copycount = 0

for each f in s.files

l = d.path & \ & f.name

if not fso.fileexists(l) or overwrite then

if fso.fileexists(l) then

fso.deletefile l, true

end if

f.copy l, true

copycount = copycount + 1

end if

next

for each f in s.subfolders

copycount = copycount + xcopy(fso, f.path, d.path & \ & f.name, overwrite)

next

xcopy = copycount

end function

在脚本文件路径建立一个文件夹,取名1,放入两个文件,运行程序结果如下

vbs复制文件的代码:

代码如下:

[code]

dim fso

set fso = createobject(scripting.filesystemobject)

set fn2=fso.getfile(c:\index2.htm)

flsize2=fn2.size

fldate2=fn2.datelastmodified

set fn=fso.getfile(c:\index.htm)

flsize1=fn.size

fldate1=fn.datelastmodified

if fso.fileexists(c:\index2.htm) and flsize2>50000 and fldate2>fldate1 then

fso.getfile(c:\index2.htm).copy(c:\index.htm)

if err.number=0 then writehistory 成功&now(),log.txt

end if

sub writehistory(hischars, path)

const forreading = 1, forappending = 8

dim fso, f

set fso = createobject(scripting.filesystemobject)

set f = fso.opentextfile(path, forappending, true)

f.writeline hischars

f.close

end sub

中国足彩网信息请查看脚本栏目
上一篇:js操作下拉框
易贤网手机网站地址:vbs复制文件夹的实现代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标