fix(BtnDisplayRename_Click):在重命名前检查路径

This commit is contained in:
薄奚梦灵
2025-03-04 12:04:17 +08:00
committed by GitHub
parent 40e0afefdd
commit 80a004ceef
2 changed files with 11 additions and 2 deletions
@@ -216,8 +216,6 @@ Public Class ValidateFolderName
End Sub
Public Overrides Function Validate(Str As String) As String
Try
'检查是否已存在
If Not Str = "" AndAlso Directory.Exists($"{Path}\{Str}") Then Return "指定的名称已存在"
'检查是否为空
Dim LengthCheck As String = New ValidateNullOrWhiteSpace().Validate(Str)
If Not LengthCheck = "" Then Return LengthCheck
@@ -124,6 +124,17 @@
Log(ex, "重命名读取 json 时失败")
JsonObject = PageVersionLeft.Version.JsonObject
End Try
If Directory.Exists(NewPath) OrElse Directory.Exists(TempName) Then
Select Case MyMsgBox("当前文件夹已存在此名称,请重新输入一个有效的名称。", "重命名失败", Button1:="确定", Button2:="取消")
Case 1
GoTo ReType
Case 2
Exit Sub
End Select
ElseIf Not Directory.Exists($"{PathMcFolder}\versions") Then
MyMsgBox("当前版本文件夹无效,请检查版本文件夹。", "重命名失败")
Exit Sub
End If
'重命名主文件夹
My.Computer.FileSystem.RenameDirectory(OldPath, TempName)
My.Computer.FileSystem.RenameDirectory(TempPath, NewName)