As new projects packEXE, adding an external file as an embedded resource f.exe as:
Add code:
using System.Reflection;//++ using System.IO; namespace packEXE { /// <Summary> /// interaction logic of MainWindow.xaml /// </ Summary> public partial class the MainWindow: the Window { public MainWindow() { InitializeComponent(); //MessageBox.Show(System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetTempFileName())); String projectName = Assembly.GetExecutingAssembly().GetName().Name.ToString(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(projectName + ".f.exe")) { Byte[] b = new Byte[stream.Length]; stream.Read(b, 0, b.Length); string s = System.IO.Path.GetTempPath()+"f.exe"; if (File.Exists(s)) File.Delete(s); using (FileStream f = File.Create(s)) { f.Write(b, 0, b.Length); } } } } }
Then, you can call free to f.exe files, you can also delete the run out without leaving any traces. (Author: Sword)
Of course, if you are a .net EXE file, there is an easier way to embed calls the reference " Dll embedded in WPF ."
Reproduced in: https: //www.cnblogs.com/aswordok/p/3751769.html