Running/using binary file in custom action

May 27, 2016 at 1:08 PM

I have added some binary files to the managed project. In custom actions I can read these binaries using method ReadBinary in the session object. Is there also any way for getting some path to these binaries to open them directly for example by using FileStream?

Thanks in advance.
May 28, 2016 at 7:49 AM
Edited May 30, 2016 at 7:57 AM
Hi Tibor,

Adding binaries to MSI and then reading them from msi DB is nothing else but a use case of adding user specified binaries to the resources and reading them at runtime. The binary itself is not deployed thus you cannot possibly read it from any directory. Instead your binary is a memory area that you can access and copy the all bytes from. Thus if for whatever reason you want to read it from file then you need to save the bytes to the file and then read them.

If your objective is to deal with the data as a stream then you can just wrap your bytes into a memory stream. Something like new MemoryStream(byte[] data)

BTW, you can achieve the same functionality without even touching your msi, thanks to the fact that you are using managed project. Thus you can add your binary to the C# project resources and read them at runtime as with any .NET application.
May 30, 2016 at 7:44 AM
Thank you for your hints Oleg.