Reputation: 32680
I'm using IPersistFile in C# to load a file, before reading it as an IFilter:
IFilter filter = LoadIFilter (fileextension);
IPersistFile persistFile = (filter as IPersistFile);
if (persistFile != null) {
persistFile.Load (fileName, 0);
IFILTER_FLAGS flags;
IFILTER_INIT iflags = IFILTER_INIT.FILTER_OWNED_VALUE_OK;
if (filter.Init (iflags, 0, IntPtr.Zero, out flags) == IFilterReturnCode.S_OK) {
return filter; // will be read using GetChunk/GetText
}
}
This works fine.
However, I would like to load the file contents from memory instead of a disk path. Is that possible? The IPersistFile interface does not show any other way than providing a path string, so it seems neither a memory mapped file nor a byte array can be used.
Upvotes: 2
Views: 1180
Reputation: 32680
As a preleminary answer sketch: My research indicates that it might be possible to cast to IPersistStream instead of IPersistFile, which allows loading from an IStream and thus from a memory target.
Upvotes: 1