我正在编写一个程序,如果它们被用户选择,它将运行一些批处理文件。
每个批次在特定的“资源”文件夹中都有自己的文件夹。
我正在遍历该文件夹以创建复选框和标签。一切正常,但我不希望标签包含整个路径 - 我只想显示文件夹名称。
代码 :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim BatchFolder As IEnumerable = Directory.EnumerateFileSystemEntries(appPath & "/resources")
Dim totalNumber As Integer = Directory.GetDirectories(appPath & "/resources").Length
Dim i As Integer = 1
For Each dir As String In BatchFolder
Dim Label As New Label()
Label.Name = "Lb_" & dir
Label.Text = dir & ".bat"
Label.AutoSize = True
Label.Visible = True
Label.Location = New Point(55, 4 + 25 * i)
Dim CustomCheckbox As New Bunifu.Framework.UI.BunifuCheckbox()
CustomCheckbox.Visible = True
CustomCheckbox.Name = "CB_" & dir
CustomCheckbox.Checked = False
CustomCheckbox.Location = New Point(35, 25 * i)
CustomCheckbox.CheckedOnColor = Color.FromArgb(12, 106, 255)
Panel5.Controls.Add(Label)
Panel5.Controls.Add(CustomCheckbox)
i = i + 1
Next
Label21.Text = totalNumber
End Sub
这是它的外观: