Store files in C# EXE file

前端 未结 4 1661
后悔当初
后悔当初 2021-01-07 03:25

It is actually useful for me to store some files in EXE to copy to selected location. I\'m generating HTML and JS files and need to copy some CSS, JS and GIFs.

Snipp

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 03:39

    You can embed binary files in a .resx file. Put them in the Files section (it looks like you used the Images section instead). It should be accessible as an array of bytes if your .resx file generates a .Designer.cs file.

    File.WriteAllBytes(@"C:\foobar.exe", Properties.Resources.foobar);
    

提交回复
热议问题