?? 文件分割器.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "文件分割器"
ClientHeight = 2955
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2955
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
Height = 285
Left = 3330
TabIndex = 5
Top = 2520
Width = 915
End
Begin VB.CommandButton Command1
Caption = "分割"
Height = 285
Left = 3330
TabIndex = 4
Top = 2070
Width = 915
End
Begin VB.TextBox Text2
Height = 270
Left = 1305
TabIndex = 3
Top = 2475
Width = 1680
End
Begin VB.FileListBox File1
Height = 1890
Left = 2970
TabIndex = 2
Top = 45
Width = 1590
End
Begin VB.DirListBox Dir1
Height = 1350
Left = 90
TabIndex = 1
Top = 540
Width = 2715
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 90
TabIndex = 0
Top = 90
Width = 2040
End
Begin VB.Label Label3
Caption = "分割大小:"
Height = 195
Left = 135
TabIndex = 8
Top = 2520
Width = 915
End
Begin VB.Label Label2
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 240
Left = 1305
TabIndex = 7
Top = 2115
Width = 1680
End
Begin VB.Label Label1
Caption = "原文件大小:"
Height = 195
Left = 135
TabIndex = 6
Top = 2115
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Fname As String
Dim Fsize As Long
Dim SplitSize As Long
Private Sub Command1_Click()
If Fname <> "" And SplitSize <> 0 Then
SplitFile Fname, SplitSize, Fsize
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo err
Dir1.Path = Drive1.Drive
err:
End Sub
Private Sub File1_Click()
If File1.ListCount > 0 Then
Fname = IIf(Len(File1.Path) > 3, File1.Path & "\" & File1.FileName, File1.Path & File1.FileName)
Fsize = FileLen(Fname)
Label2.Caption = Trim(Str(Fsize)) & " Bytes"
End If
Form1.Caption = "文件分割器"
End Sub
Private Sub SplitFile(Fname As String, SplitSize As Long, Fsize As Long)
Dim Buff() As Byte
Dim FileNum As Long
Dim Fnum As Long
Dim Fnum1 As Long
Dim SaveName As String
Dim OldName As String
Dim BATfile As String
Dim SavePath As String
If SplitSize >= Fsize Then
MsgBox "分割大小等于或大于原文件大小", vbInformation
Exit Sub
End If
Fnum = FreeFile
SavePath = IIf(Len(App.Path) > 3, App.Path & "\", App.Path)
BATfile = "copy /B "
Open Fname For Binary As Fnum
FileNum = IIf(CLng(Fsize / SplitSize) >= Fsize / SplitSize, CLng(Fsize / SplitSize), CLng(Fsize / SplitSize) + 1)
If Dir(Left(SavePath, Len(SavePath) - 1), vbDirectory) = "" Then
MkDir (Left(SavePath, Len(SavePath) - 1))
End If
For i = 1 To FileNum
SaveName = SavePath & Left(File1.FileName, Len(File1.FileName) - 4) & "." & Format(i - 1, "000")
If i < FileNum Then
ReDim Buff(SplitSize - 1) As Byte
Get #Fnum, , Buff
BATfile = BATfile & SaveName & "+"
Else
ReDim Buff(Fsize - (FileNum - 1) * SplitSize - 1)
Get #Fnum, , Buff
BATfile = BATfile & SaveName & " "
End If
OldName = SaveName
Fnum1 = FreeFile
Open SaveName For Binary As Fnum1
Put #Fnum1, 1, Buff
Close #Fnum1
Form1.Caption = "已完成" & Format(i / FileNum, "###%")
DoEvents
Next i
Fnum1 = FreeFile
BATfile = BATfile & SavePath & File1.FileName
Open SavePath & "FileLink.bat" For Output As #Fnum1
Print #Fnum1, BATfile
Close #Fnum1
Close #Fnum
End Sub
Private Sub Text2_Change()
On Error Resume Next
SplitSize = CLng(Text2.Text)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -