How can I inject a file into an EXE at runtime and reference the file during program operation?

后端 未结 5 1244
时光取名叫无心
时光取名叫无心 2021-02-06 11:22

I\'d like a user to download an exe from my website, where (synchronously upon download) an XML file is injected into this application. This XML file contains a public key, and

5条回答
  •  梦毁少年i
    2021-02-06 11:39

    Add the file to your project, typically something along the lines of:

    +solution
      +project
        +Resources
          +SomeDirectory
            -SomeFile
    

    Then go to your project's properties, go to the resources tab on the left site and select the files resource on the top nav bar. Select to add a resource > add existing file. Browse to the file you just put into your project and select to add it.

    The file will now show up under your Resources tab of your project's properties. Change the name of your file in the Resources tab to be more meaningful.

    The file is now an embedded resource of your project and you can access it by the following in code:

    var MyFile = Properties.Resources.MyFile
    

提交回复
热议问题