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

How to use VB.NET FileCopy statement

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use the VB.NET FileCopy sentence, the article is very detailed, has a certain reference value, interested friends must read it!

The VB.NET FileCopy statement is still quite commonly used, so I studied the VB.NET FileCopy sentence and took it out here to share with you. I hope it will be useful to you. The function of the FileCopy statement is to copy a file, and its syntax is as follows:

FileCopy source,destination

The syntax of the FileCopy statement includes two parameters, where soure is used to represent the name of the source file to be copied, and destination is used to specify the name of the destination file to be copied. Include the directory or folder where the files are located and the drive in both the source and destination parameters.

The following is an example of a program that uses VB.NET FileCopy statements to copy files.

1. Design interface

Add a Commondialog control to the toolbox and place it on a blank form.

According to the functional requirements of the program, two CommandButton controls, two TextBox controls and two Label controls are added to the form.

two。 Write initialization code for the program

Define two global variables in the program declaration, one to store the path and name of the source file, and the other to store the path and name of the destination file

Dim source as string 'defines a string variable that stores the path and name of the source file. Dim destination as string 'defines a string variable that stores the path and name of the destination file.

3. Respond to the click event of the [Open] button

Double-click the Open button at design time to add the following code to the pop-up code window:

Private Sub Command1_click () CommonDialog1.showopen 'displays a dialog box source=CommonDialog1.filename' stores the string variable text1.text=source End Sub for the path and name of the source file

Program description: the program first displays a dialog box through the CommonDialog1.show statement, in which the user may select the source file to copy, and then store the path and file name of the selected source file in the variable soure, while displaying the path and file name of the source file in the text box through Text1.text=source.

4. Respond to the click event of the [Save as] button

Double-click the Save as button at design time to add the following code to its Command2_Click () event:

Private Sub Command2_click () CommonDialog1.showsave 'display a dialog box destination=CommonDialog1.Filename' stores the destination file path and name string variable Text2.text=destination 'display the destination file path? / FONT > above is all the content of the article "how to use the VB.NET FileCopy statement". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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