Read a file from a resource and write it to disk in C#

前端 未结 3 450
无人共我
无人共我 2021-01-22 05:32

I have some files, which are embedded in a resource. How can I save these files on disk via C#?

3条回答
  •  温柔的废话
    2021-01-22 05:41

    This should do your job:

            string strTempFile = Path.GetTempFileName();
            File.WriteAllBytes(strTempFile, Properties.Resources.YourBinaryFileInResource);
    

    Be sure, that the FileType of the included files is set to "binary".

提交回复
热议问题