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 the VB.NET file processing function kill statement

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use the VB.NET file processing function kill statement, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Have not used functions to operate on files before, now in VB6.0, in addition to using file controls to deal with files, you can also use some functions and methods to deal with files, commonly used VB.NET file processing functions and methods are Kill,FileCopy.RmDir,Shell and Name, and so on.

VB.NET file processing function Kill statement

The function of the Kill statement is to delete files from disk, and its syntax structure is as follows:

Killpathname

Where the parameter pathname is a string expression used to specify a file name, and pathname contains the directory (folder) where the file is located and the drive.

Kill supports multiple characters (*) and single characters (? To specify multiple files For example:

Kill "c:\ xy\ * .bak"

The backup files in the xy directory of disk c will be deleted.

The Kill statement is "dangerous" because there is no prompt when the statement is executed.

The following is an example of designing an application using the kill statement (see textbook P336). The function it can achieve is to display a dialog box, select a file to be deleted in the dialog box, and then the system automatically completes the deletion action. the specific steps are as follows:

1. Design interface

First add a CommonDialog control to the toolbox, and then add it to the blank form.

two。 Add code

A dialog box to delete files is displayed at the beginning of the program, so double-click the form at design time and add the following code to the form's Form_load () event:

PrivateSubForm_Load () CommonDialog1.DialogTitle= "Open a file you want to delete" sets the title of the control. CommonDialog1.FileName= "* .doc" CommonDialog1.Filter= "* .doc" 'sets the filter. CommonDialog1.showopen' displays a dialog box. IfCommonDialog1.FileName= "* .doc" Then Else KillCommonDialog1.FileName' deletes the selected file EndIf EndSub

3. Save the file, run the program

Note: when deleting a file with the VB.NET file processing function Kill statement, you must close the file, or there will be an error.

The above is all the contents of the article "how to use the kill statement of VB.NET file processing function". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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