The files in the above list are not from allJpgFile, but from
This file.
Merging multiple files into one file is very useful in many application fields. Self-implementation of such a program will not only be enjoyable, but will often help us build more efficient programs. Here I will share my case with you.
Because the merged file is like a package, this file is called "package file" in the following sections"
Main Idea:
To Merge multiple files into a package file, you can also distinguish a file and extract it. We need to know the file name and the location and length of the file in the package file, that is, the so-called address offset.
Because the package file is often large, you should not keep its content in the memory. Instead, you must extract some of the content from the package file.
I did this:
A manager class that provides some peripheral Methods
_ PathListUsed to store the file path to be added to the package file.AddSourceFile ()Add Method
_ PfIs a specific package file, throughLoadPackFile ()Generate an instanceCurrentPackFileProperty return
BuildMethod used to generate a package file
PackFileClassPackFileManagerIt provides the attributes and construction details of the package file.
Okay. Let's take a look.PackFileManager. Build ()Method
Public VoidBuild (StringPath)
{
Using(FileStreamFs =New FileStream(Path,FileMode. Create,FileAccess. Write ))
{
BinaryWriterBw =New BinaryWriter(Fs );
Bw. Write ("PackFile");
Bw. Write (This. _ PathList. Count );
Foreach(StringFIn This. _ PathList)
{
FileInfoFi =New FileInfo(F );
Bw. Write (fi. Length );
Fi =Null;
}
Foreach(StringFIn This. _ PathList)
{