Home > Software engineering >  How to combine the file and then use the segmentation?????? Existing prototype code, as I want to ch
How to combine the file and then use the segmentation?????? Existing prototype code, as I want to ch

Time:10-10

Read online write very long, but I can't use,,,,,,,

What I want is: C: \ MyFile folder named 1. MPQ and all called *. DSS file package, (C: \ MyFile and other essays), and recovery or back to 1. The MPQ. And *. Was the original name, to DSS,



This is my online, should how to change I want??

 'it should be a document segmentation and merging problem 
'this is what I write before, slightly modified to provide to you, hope to useful
'example: C: \ MyFile directory file into C: \ MyText. TXT
'suppose this directory have two files: My1. TXT, My2. TXT, these two files are not empty file
'in fact any file type can merge, the merged file can be arbitrary extension
'first, add the controls on the form: File1, Command1, Command2

Private Sub Form_Load ()
Command1. Caption="merge files"
Command2. Caption="extract file"
File1. Path="c: \ MyFile"
File1. The Pattern="*"
End Sub

Private Sub Command1_Click ()
'merge files
Dim H As Long, F As String, I As Long, the Info As String
Dim H1, As Long As the String, F1 () As Byte B, S As Long
Dim S1 As Long, nS As String, nPath As String

'in a binary way to open a file, ready to more than one file is written to the
If File1. ListCount=0 Then the Exit Sub
NPath=File1. Path
If Right (nPath, 1) & lt;> "" Then nPath=nPath & amp; ""

H=FreeFile
F="C: \ MyText. TXT" 'combined large file name, can take arbitrary extension
If Dir (F) & lt;> "" Then Kill F
The Open F For Binary As # H

For I=0 To File1. ListCount - 1
F1=nPath & amp; File1. List (I) 'to merge a file
S=FileLen (F1)
If the S & lt; 1 Then GoTo XiaI
ReDim B (1) To S
H1=FreeFile
The Open F1 For Binary As # H1
The Get # H1, B 'read out data from F1
Close # H1

S1=the Seek (H)
Info=Info & amp; S1 & amp; "& lt;" & S & amp; "& gt;" & F1 & amp; Message: "|" "record F1 starting location, file size, file name
Put # H, B 'to write data into the F
XiaI:
Next

'Info format is: the starting location, file size, file name | starting location, file size, file name |... | the Info the number of bytes (10)
S1=10 + LenB (StrConv (Info, vbFromUnicode))
NS=S1
If Len (nS) & lt; 10 Then nS=nS & amp; String (10 - Len (nS), "-")
B=StrConv (Info & amp; NS, vbFromUnicode)
Put # H, B 'will merge information written to a file at the end of the

Close # H
End Sub

Private Sub Command2_Click ()
'take out the original file before merger
Dim H As Long, F As String, S As Long, S1 As Long, () As Byte B
Dim nStr As String, F1 As String, H1 As String
Dim StartS As Long, LongS As Long, Str1 As String, S2 As Long

H=FreeFile
F="C: \ MyText. TXT" 'combined large files
S=FileLen (F)
The Open F For Binary As # H

'read 10 bytes at the end, the number of bytes to merge information
The Seek H, S - 9
ReDim B (1 To 10)
Get # H, B
NStr=B
NStr=StrConv (nStr, vbUnicode)
S1=Val (nStr)

'read to the end of S1 bytes, merging information string
The Seek H, S - S1 + 1
ReDim (1 B To S1)
Get # H, B
NStr=B
NStr=StrConv (nStr, vbUnicode)

MsgBox "information before merger:" & amp; VbCrLf & amp; NStr & amp; VbCrLf & amp; "From the first file is saved as: C: \ My - 1. TXT", vbInformation, "extract file
"
'the next thing, is to analyze the string nStr
'the following code is to extract the first file data, saved as C: \ My - 1. TXT
'trust through appropriate modified, extract other files or all files, you can get yourself

S1=InStr (nStr, & lt; "" )
Str1=Left (nStr, S1-1)
StartS=Val (Str1) 'the beginning of the file data position

S2=InStr (S1 + 1, nStr, & gt; "" )
Str1=Mid (nStr, S1 + 1, S2 - S1-1)
LongS=Val (Str1) 'the original file size

'read the original file data from F
The Seek H, StartS
ReDim (1 B To LongS)
Get # H, B

'
to save data to a file F1F1="C: \ My - 1. TXT" 'according to the content changes of nStr
If Dir (F1) & lt;> "" Then Kill F1

H1=FreeFile
The Open F1 For Binary As # H1
Put # H1, B
Close # H1

Close # H

End Sub

CodePudding user response:

One more thing,,,,, the combined file extension called, osk

CodePudding user response:

Does anyone know???????

CodePudding user response:

@ of123
Please help ~

CodePudding user response:

Compression and decompression, a lot of online resources, it is ok, baidu why here to ask for help

CodePudding user response:

reference 4 floor CityBird response:
compression and decompression, and a lot of online resources, oneself baidu, why here to seek help


A novice what all not,,,,,,,, and this would not be compressed,,,,,,,,

CodePudding user response:

Someone didn't ah,,,,,,,,,,,
  • Related