⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbs268.htm

📁 VBScript 是一种脚本语言
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>
<HEAD>
<TITLE>CopyFile Method</TITLE> 
<META NAME="CATEGORY" CONTENT="Language Reference"> 
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
<META NAME="PRODUCT" CONTENT="Visual Basic Scripting Edition">
<META NAME="TECHNOLOGY" CONTENT="SCRIPTING">
<META NAME="Description" CONTENT="CopyFile Method">
<META NAME="Keywords" CONTENT="">
</HEAD>
<BODY BGCOLOR=FFFFFF LINK=#0033CC>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR VALIGN=TOP><TD WIDTH=360>
<FONT SIZE=1 COLOR=#660033>Microsoft&#174; Visual Basic&#174; Scripting Edition</FONT><BR>
<FONT SIZE=5 COLOR=#660033><B>CopyFile Method</B></FONT></TD>


<TD ALIGN=RIGHT>
<FONT SIZE=2>&nbsp;<A HREF="vbstoc.htm">Language&nbsp;Reference</A>&nbsp;<BR><A HREF="vbs16.htm">Version&nbsp;3</A>&nbsp;<P></FONT>

</TD></TR>
</TABLE> 

<FONT SIZE=2><p>
<A HREF="vbs270.htm">See Also</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="vbs269.htm">Applies To</A></FONT>
<HR noshade SIZE=1>

<H5>Description</H5>
<BLOCKQUOTE>Copies one or more files from one location to another.</BLOCKQUOTE>

<H5>Syntax</H5>
<BLOCKQUOTE><i>object</i>.<b>CopyFile</b> <i>source</i>, <i>destination</i>[, <i>overwrite</i>]

<P>The <b>CopyFile</b> method syntax has these parts:
<P>
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Part</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>object</i></FONT></TD>
<TD><FONT SIZE=2>Required. The <i>object</i> is always the name of a <b>FileSystemObject</b>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>source</i></FONT></TD>
<TD><FONT SIZE=2>Required. Character string file specification, which can include wildcard characters, for one or more files to be copied.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>destination</i></FONT></TD>
<TD><FONT SIZE=2>Required. Character string destination where the file or files from <i>source</i> are to be copied. Wildcard characters are not allowed.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>overwrite</i></FONT></TD>
<TD><FONT SIZE=2>Optional. Boolean value that indicates if existing files are to be overwritten. If <b>True</b>, files are overwritten; if <b>False</b>, they are not. The default is <B>True</B>. Note that <b>CopyFile</b> will fail if <i>destination</i> has the read-only attribute set, regardless of the value of <i>overwrite</i>.</FONT></TD></TR>  
</TABLE></BLOCKQUOTE>

<H5>Remarks</H5>
<BLOCKQUOTE>
Wildcard characters can only be used in the last path component of the <i>source</i> argument. For example, you can use:

<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
</FONT></PRE></BLOCKQUOTE> 
But you can't use:
<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>FileSystemObject.CopyFile "c:\mydocuments\*\R1???97.xls", "c:\tempfolder"
</FONT></PRE></BLOCKQUOTE> 
If <i>source</i> contains wildcard characters or <i>destination</i> ends with a path separator (\), it is assumed that <i>destination</i> is an existing folder in which to copy matching files. Otherwise, <i>destination</i> is assumed to be the name of a file to create. In either case, three things can happen when an individual file is copied.
<UL>
<li>If <i>destination</i> does not exist, <i>source</i> gets copied. This is the usual case.
<li>If <i>destination</i> is an existing file, an error occurs if <i>overwrite</i> is <b>False</b>. Otherwise, an attempt is made to copy <i>source</i> over the existing file.
<li>If <i>destination</i> is a directory, an error occurs.
</UL>

An error also occurs if a <i>source</i> using wildcard characters doesn't match any files. The <b>CopyFile</b> method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.

</BLOCKQUOTE>
<hr noshade size=1>
<FONT SIZE=2>
<p align=center><em><a href="../../common/colegal.htm">&copy; 1997 by Microsoft Corporation. All rights reserved.</a></em></p> 
</FONT></FONT></BODY></HTML>




























































⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -