As an extension, you need to understand the usage of DotNetZip. See:
C #. NET uses a third-party class library DotNetZip to decompress/compress the Zip file
You also need to understand the basic method of the embedded resource source file of a single file. For details, refer:
WPF calls embedded non-. net EXE resource files
Author: yijian
If you have a large number of files or want to package them into resource files in any format, you can package them into a ZIP file, embedding it in a resource file is a good choice:
Using System. reflection; // ++ using System. IO; using Ionic. zip; namespace packZip {// <summary> // MainWindow. interaction logic of xaml // </summary> public partial class MainWindow: Window {
List <string> fileList = new List <string> (); public MainWindow () {InitializeComponent (); String projectName = Assembly. getExecutingAssembly (). getName (). name. toString (); using (var stream = Assembly. getExecutingAssembly (). getManifestResourceStream (projectName + ".f.zip") {Byte [] B = new Byte [stream. length]; stream. read (B, 0, B. length); MemoryStream m = new MemoryStream (B); using (ZipFile zip = ZipFile. read (m) {zip. extractAll (System. IO. path. getTempPath (), ExtractExistingFileAction. overwriteSilently );
Foreach (ZipEntry entry in zip)
{
FileList. Add (entry. FileName );
}}} Private void Window_Closing (object sender, System. ComponentModel. CancelEventArgs e) {string s = System. IO. Path. GetTempPath ();
Foreach (string f in fileList)
{
If (File. Exists (s + f ))
File. Delete (s + f );
}}}}
In this example, the file traversal and cleanup in the ZIP file are added at the end of the program, so that no trace is left after use, and the job will be brilliant.