Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of CopyFile method in VBS

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the use of CopyFile method in VBS". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "the use of CopyFile method in VBS" together!

Copy one or more files from one location to another.

object.CopyFile source, destination[, overwrite]

Parameter object

Required. Expected name of FileSystemObject object.

source

Required. A string representing the specified file. When copying one or more files, you can have wildcards in the file name.

destination

Required. A string representing the destination location to which the file is copied from the source. Wildcards are not allowed.

overwrite

Optional. Boolean value indicates whether to overwrite an existing file. If True, files are overwritten; if False, existing files are not overwritten. The default value is True. Note that regardless of the overwrite setting, the CopyFile operation cannot be completed as long as destination is set to the read-only property.

description

Wildcards can only be used in the last component of the path of the source parameter. 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"

If source contains wildcards or destination ends with a path delimiter (\), then destination is assumed to be an existing folder and matching files are copied to that folder. Otherwise, assume destination is the file to be created. In either case, when copying a single file, three things happen.

If destination does not exist, copy source. This is what usually happens.

If destination is an existing file, an error occurs when overwrite is False. Otherwise, copy source overwrites existing files.

If destination is a directory, an error occurs.

If source uses wildcards and there is no matching file, an error occurs. The CopyFile method stops on the first error that occurs. This method does not undo any changes made before the error occurred.

Thank you for reading, the above is the "VBS CopyFile method in the use of" the content of the article, after learning this article, I believe we have a deeper understanding of the use of the VBS CopyFile method, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report