WPF calls embedded non-. net EXE resource files

Source: Internet
Author: User

A new project, such as packexe, uses the external file f.exe as the embedded resource,

Add code:

Using System. reflection; // ++ using System. IO; namespace packEXE {// <summary> // MainWindow. interaction logic of xaml // </summary> public partial class MainWindow: 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 );}}}}}

After that, you can use the f.exe file as you like. You can delete the file without any trace. (Author: yijian)

Of course, if you are an. net EXE file, you can use a simpler method to embed the call. For more information, see "embed Dll into WPF ".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.