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.
Snippet
System.IO.File.WriteAllBytes(@”C:\MyFile.bin”, ProjectNamespace.Properties.Resources.MyFile);
doesn’t work for me!
On “WriteAllBytes” it says:
“cannot convert from ‘System.Drawing.Bitmap’ to ‘byte[]'”
for image and
“cannot convert from ‘string’ to ‘byte[]'”
for text file.
Help!
UPDATE: Solved below.
Add files to project resources and set their “Build Action” as “Embedded Resource”.
Now extract any file (text or binary) using this snippet:
Don’t know how deep is it correct according to this article: http://www.yoda.arachsys.com/csharp/readbinary.html
but it works.