How to use RmDir statement in VB.NET
This article will explain in detail how to use the RmDir sentence in VB.NET. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The function of the VB.NET RmDir statement is to delete an existing and empty directory or folder, and its syntax structure is as follows:
Rmdir path
Where the parameter Path is a string expression that specifies the directory or folder to delete. If no drive is specified in the parameter Path, the VB.NET RmDir statement deletes an empty directory or folder on the current drive.
The following is an example of a combination of the kill statement and the Rmdir statement, and what it can do is to delete a non-empty directory.
1. Interface design
Add a DriveListBox control, a DirListBox control, a FileListBox control, and three CommandButton controls to the form, and set the properties.
2.VB.NET RmDir statement code
In response to the Delete File button click event:
During the design phase of the program, double-click the Delete File button to add the following code to its Command2_Click () event:
Private Sub Command2_Click () Kill File1.Path+ "\" + File1.FileName 'Delete a file End Sub
Respond to the Delete Directory button event:
During the design phase of the program, double-click the delete directory button to add the following code to its Command1_Click () event:
Private Sub Command1_Click () Rmdir Dir1.Path 'delete the empty directory End Sub
Respond to the "exit run" button event:
Private sub command3_click () end 'Terminator end sub
Synchronization of drive, directory and file
Private sub dir1_change () file1.path=dir1.path 'timely change the contents of the file list box end sub private sub drive1_change () dir1.path=drive1.drive' timely change the contents of the directory list box end sub about "how to use RmDir statements in VB.NET" this article ends here. I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good Please share it for more people to see.