Visual Basic 2008 目录的创建与删除

Imports System.IO
Public Class Form1
Private Sub 创建目录_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 创建目录.Click
'定义目录
Dim 目录 As String
目录 = "c:\dyc"
If Directory.Exists(目录) Then
MsgBox("目录已经存在,现在退出")
Exit Sub
Else
Directory.CreateDirectory(目录)
MsgBox("目录创建成功")
End If
End Sub
Private Sub 删除目录_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 删除目录.Click
'定义要删除的目录
Dim 目录 As String
目录 = "c:\dyc"
If Directory.Exists(目录) Then
Directory.Delete(目录)
MsgBox("目录删除成功")
Else
MsgBox("目录不存在")
Exit Sub
End If
End Sub
End Class

你可能感兴趣的:(2008)