ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
297 stars 73 forks source link

Create Compound File from File #48

Closed 6Hat closed 1 year ago

6Hat commented 5 years ago

Sorry as I am new to compound files. I need to take a standard image in various formats... whether .jpg or .png etc and convert them to a compound file for an MS Access Bound Object Frame. I am stuck on how you take the physical image file and convert it into a MCDF however? I can find no examples.

I've tried to add the file in as a stream but this is obviously wrong: CompoundFile cf = new CompoundFile(); CFStream myStream = cf.RootStorage.AddStream(path);

What I need to get overall is the Binary Value of the compound file with the image stream within it. Any help would be greatly appreciated!

ironfede commented 1 year ago

I'm not an expert in the file format your'referencing to but if you want to store an image in a compound file you should read it in a byte array/stream for example with

byte[] b = File.ReadAllBytes(file);

and then put it into a stream

CompoundFile cf = new CompoundFile(); 
CFStream myStream = cf.RootStorage.AddStream("ImageStream");
myStream.SetData(b);
cf.Save("MyFile.dat");

Having said that, I suggest to find an example and some documentation of the relationship between MS Access Bound Object Frame and Compound files because I hvent' found one in a quick search (I may be wrong).

Best Regards, Federico