Dim dxg1 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim dxg2 As WinForm.TextBox = e.Form.Controls("TextBox2")
If dxg1.Text = Nothing Then
MessageBox.Show("请先选择【源文件夹】!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
dxg1.Select() '焦点控件
Return
End If
If dxg2.Text = Nothing Then
MessageBox.Show("请先选择【加密后文件夹】!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
dxg2.Select() '焦点控件
Return
End If
'全局代码赋值
FLn = 0
FLold = dxg1.Text
FLnew = dxg2.Text
’先对源文件夹目录下文件计数
For Each fl As String In FileSys.GetFiles(FLold)
FLn = FLn + 1
Next
'执行文件计数递归函数
For Each dir2 As String In FileSys.GetDirectories(FLold)
Functions.Execute("文件计数", dir2)
Next
If FLn < 1 Then
MessageBox.Show("【源文件夹】无文件,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
dxg1.Select() '焦点控件
Return
End If
Dim Result As DialogResult
Result = MessageBox.Show("需要加密【" & FLn & "】个文件,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.NO Then
Return
End If
Dim Floldn As Integer = FLn '变换变量
'全局代码初始化
FLn = 0
’先对源文件夹目录下文件加密
For Each fl As String In FileSys.GetFiles(FLold)
EncryptFile(fl, fl.Replace(FLold, FLnew), "Qtkj")
FLn = FLn + 1
Next
'执行文件加密递归函数
For Each dir2 As String In FileSys.GetDirectories(FLold)
If FileSys.DirectoryExists(dir2.Replace(FLold, FLnew)) Then '如果加密后目录不存在则创建之
Else
FileSys.CreateDirectory(dir2.Replace(FLold, FLnew))
End If
Functions.Execute("文件加密", dir2)
Next
MessageBox.Show("需要加密【" & Floldn & "】个文件,加密成功【" & FLn & "】个文件,加密失败【" & Floldn - FLn & "】个文件!", "提示",MessageBoxButtons.OK)
'恢复全局代码初始值
FLold = ""
FLnew = ""
FLn = 0
'打开加密后文件夹
Dim proc As New Process
proc.File = dxg2.Text
proc.Start