Store files in C# EXE file

前端 未结 4 1703
后悔当初
后悔当初 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:55

    I assume you added the files through the Project Properties window. That does not allow you to add an arbitrary file but it does support TextFiles, Bitmaps and so on.

    For an embedded TextFile, use

      File.WriteAllText(@"C:\MyFile.bin", Properties.Resources.TextFile1);
    

    For an Image, use

      Properties.Resources.Image1.Save(@"C:\MyFile.bin");
    

提交回复
热议问题