0

Possible Duplicate:
load resource as byte array programmaticaly
Store Image in .resx as byte[] rather than Bitmap

I am creating a web service that will enable users to download several files. I keep those files on Resources.resx . The problem is that if I add a binary (someProgram.exe) file to Resources.resx then doing:

 var foo = Resources.someProgram; // Foo is of type byte[]!

and if I then add an image to Resources.resx (someImage.png) then:

 var foo2 = Resources.someImage; // Foo2 is of type Bitmap

I want all files on resources to be treated as binary. How can I do that? The moment I add an image it is of type Bitmap. How can I force it to be binary?

Edit

One solution would be to remove the file extension but I want to keep the files with their file extension...

Community
  • 1
  • 1
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
  • 1
    Just change the extension of your images like this: MyImage.bmp -> MyImage.bmp.bin and then you embed them in resources and they will be treated as binaries. – Tommaso Belluzzo Jan 15 '13 at 20:02
  • 1
    I asked a similar question here http://stackoverflow.com/questions/9901518/store-image-in-resx-as-byte-rather-than-bitmap – Grokodile Jan 15 '13 at 20:04
  • You can use ResXResourceWriter to store resources as streams if you really want to use resx. The streams can be further used to get byte array no matter the stream source. Question closed to early? – alexb Jan 15 '13 at 21:03

0 Answers0