How To Store Files In An EXE

后端 未结 4 1599
轻奢々
轻奢々 2020-12-13 06:52

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(fi

4条回答
  •  清歌不尽
    2020-12-13 07:17

    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);
    

提交回复
热议问题