如何将文件存储在一个EXE [英] How To Store Files In An EXE
问题描述
好了,所以我正在编程在C#中我自己的安装程序,以及我想要做的就是一起把文件中的.exe线的东西,所以我可以做
档。复制(文件,FILEDIR);
Alright, so I'm working on programming my own installer in C#, and what I'd like to do is something along the lines of put the files in the .exe, so I can do File.Copy(file, filedir);
或者,如果这是不可能的,有没有做什么,我试图做的。
Or, if this isn't possible, is there another way of doing what I am attempting to do?
推荐答案
我不会代码我自己的安装程序,但如果你忠实地要嵌入文件到您的程序集,你可以使用强类型的资源。在项目的属性对话框中打开资源选项卡,然后添加您的文件。然后,您就可以开始使用该文件:
I wouldn't code my own installer, but if you truely want to embed files into your assembly you could use strongly typed resources. In the properties dialog of your project open up the "Resources" tab and then add your file. You'll then be able to get the file using:
ProjectNamespace.Properties.Resources.MyFile
然后,你就可以使用到嵌入的资源写入到磁盘:
Then you'll be able to write the embedded resource to disk using:
System.IO.File.WriteAllBytes(@"C:\MyFile.bin", ProjectNamespace.Properties.Resources.MyFile);
这篇关于如何将文件存储在一个EXE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!