0 Star 0 Fork 0

drgonfly/eXiu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
FrmMain.vb 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
drgonfly 提交于 2015-04-24 15:27 . new file
Public Class frmMain
Private Sub btnChooseDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChooseDir.Click
Dim folderDialog As New FolderBrowserDialog
folderDialog.RootFolder = Environment.SpecialFolder.Desktop
If (folderDialog.ShowDialog() = DialogResult.OK) Then
Me.txtDirectory.Text = folderDialog.SelectedPath
LoadFiles(Me.txtDirectory.Text.ToString, ListView1)
Else
End If
End Sub
Sub LoadFiles(ByVal path As String, ByRef objlistview As ListView)
Dim files() As String
objlistview.Items.Clear()
If Dir(path, FileAttribute.Directory) <> "" Then
files = IO.Directory.GetFiles(path)
For Each f As String In files
objlistview.Items.Add(f)
Next
End If
End Sub
Private Sub BtnModifyFileName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnModifyFileName.Click
Dim newfilename As String = ""
Dim oldfilename As String = ""
Dim delC As String = ""
Dim sing As Boolean = False
Dim counts As Integer = 0
delC = txtCharacter.Text.ToString
If delC = "" Then
MsgBox("还没设置要剔除文件名中的字符呢", MsgBoxStyle.Information)
txtCharacter.Focus()
Exit Sub
End If
If ListView1.Items.Count <= 0 Then Exit Sub
For i As Integer = 0 To ListView1.Items.Count - 1
oldfilename = ListView1.Items(i).Text.ToString
If oldfilename.Contains(delC) Then
sing = True
counts = counts + 1
newfilename = oldfilename.Replace(delC, "")
FileSystem.Rename(oldfilename, newfilename)
End If
Next
If sing Then
LoadFiles(Me.txtDirectory.Text.ToString, ListView1)
MsgBox("" & counts & "个文件名中的字符 " & delC & " 清除完毕!")
txtCharacter.SelectAll()
End If
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.View() = View.List
Label3.ForeColor = Color.Red
End Sub
Private Sub txtCharacter_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCharacter.KeyPress
Static invalidateCharactor As String = "<>/\?""|:*"
If invalidateCharactor.IndexOf(e.KeyChar) >= 0 Then
e.Handled = True
Label3.Text = "文件名中不得含有" & invalidateCharactor & "其中的任何一个字符!"
Else
e.Handled = False
Label3.Text = ""
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Application.Exit()
End Sub
End Class
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Visual Basic
1
https://gitee.com/drgonfly123/eXiu.git
[email protected]:drgonfly123/eXiu.git
drgonfly123
eXiu
eXiu
master

搜索帮助