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 delete a folder by VB.NET

2025-01-17 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 delete VB.NET folders, I believe that 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!

VB.NET delete folder code:

Option Explicit Private Sub Command1_Click () Dim strPathName As String strPathName = "" strPathName = InputBox ("Please enter the folder name to be deleted ∶", "delete folder") If strPathName = "Then Exit Sub On Error GoTo ErrorHandle SetAttr strPathName, vbNormal 'this line is mainly to check the validity of the folder name RecurseTree strPathName Label1.Caption =" folder "& strPathName &" deleted! " Exit Sub ErrorHandle: MsgBox "invalid folder name: & strPathName End Sub Sub RecurseTree (CurrPath As String) Dim sFileName As String Dim newPath As String Dim sPath As String Static oldPath As String sPath = CurrPath &"\ "sFileName = Dir (sPath, 31)'31 meaning ∶ 31=vbNormal+vbReadOnly+vbHidden+vbSystem+vbVolume+vbDirectory Do While sFileName"If sFileName". " And sFileName ".." Then If GetAttr (sPath & sFileName) And vbDirectory Then'if it is a directory and folder newPath = sPath & sFileName RecurseTree newPath sFileName = Dir (sPath, 31) Else SetAttr sPath & sFileName, vbNormal Kill (sPath & sFileName) Label1.Caption = sPath & sFileName 'shows the deletion process sFileName = Dir End If Else sFileName = Dir End If DoEvents Loop SetAttr CurrPath, vbNormal RmDir CurrPath Label1.Caption = CurrPath End Sub above is all the contents of the article "how VB.NET deletes folders". 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