As far as I am aware, you will get an error if you try to load large file sizes using the function IMemoryBlobStream.LoadFromFile().
Has anyone found some workaround code to load a file into a IMemoryBlobStream?
What I am trying to do is just insert a PDF document file into a BLOB in an Oracle database, but I am not, and do not want to use Oracle API's. I am just using ArcOjects for this one.
My code looks like:
public void LoadReport(string fileName)
{
try
{
if (File.Exists(fileName))
{
IMemoryBlobStream2 memoryBlobStream = new MemoryBlobStreamClass();
memoryBlobStream.LoadFromFile(fileName);
report = memoryBlobStream;
}
}
catch (Exception ex) {
throw ex;
}
}
UPDATE
This is the code I have put to finally get the file in the database, now just need to check reading out the file from the BLOB - hopefully it should work.
fs = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
byte[] bytes = new byte[fs.Length];
int chunkSize = 2 << 17;
int pos = 0;
for (pos = 0; pos < (fs.Length - chunkSize); pos += chunkSize)
{
fs.Read(bytes, pos, chunkSize);
}
long modResult = (fs.Length % chunkSize);
fs.Read(bytes, pos,Convert.ToInt32(modResult));
IMemoryBlobStream2 memoryBlobStream = new MemoryBlobStreamClass();
memoryBlobStream.ImportFromMemory(ref bytes[0], (uint)bytes.Length);
fs.Close();