Vbs Tutorial: method-copyfile Method

Source: Internet
Author: User

Copyfile Method

Copy one or more files from one location to another.

Object.CopyfileSource, destination [, overwrite]

Parameters

Object

Required. The name of the FileSystemObject object.

Source

Required. Indicates the string of the specified file. To copy one or more files, the file name can contain wildcards.

Destination

Required. String indicating the target location, fromSourceCopy the file to this location. Wildcards are not allowed.

Overwrite

Optional. Boolean indicates whether to overwrite existing files. If yesTrueTo overwrite the file.FalseDoes not overwrite the existing file. The default value isTrue. Note thatOverwriteSet the value.DestinationIs read-only,CopyfileThe operation cannot be completed.

Description

OnlySourceWildcard characters are used in the last component of the parameter path. For example, you can use:

FileSystemObject. copyfile "C: \ mydocuments \ letters \ *. Doc", "C: \ tempfolder \"

However, you cannot use:

 
FileSystemObject. copyfile "C: \ mydocuments \ * \ R1 ??? 97. xls "," C: \ tempfolder"

IfSourceContains wildcards orDestinationEnd with path separator (\), it is assumedDestinationIs an existing folder, copy the matching file to this folder. Otherwise, assumeDestinationFor the file to be created. In either case, the following three conditions may occur when copying a single file.

    • IfDestinationIf not, copySource. This is usually the case.
    • IfDestinationIs an existing file, whenOverwriteIsFalseAn error occurs. Otherwise, copySourceOverwrite existing files.
    • IfDestinationIs a directory, an error occurs.

IfSourceIf a wildcard is used but no matching file exists, an error occurs.CopyfileMethod stops when the first error occurs. This method does not cancel any changes made before the error occurs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.