The following code does not correctly ready the ThumbnailBitmap property:
using (Database OpenDb = new Database(false, false))
{
OpenDb.ReadDwgFile("c:\temp\test.dwg",
FileOpenMode.OpenForReadAndWriteNoShare, true, "");
Bitmap thumbNail = OpenDb.ThumbnailBitmap;
if (thumbNail == null)
{
//
}
else
{
//
}
}
This is because the DWG file has been opened without share permission, and so the ThumbnailBitmap property is unable to query the DWG file for the bitmap. (For performance reasons, the bitmap is read on demand from the DWG file).
The solution is to open the DWG with share permission, for example:
using (Database OpenDb = new Database(false, false))
{
OpenDb.ReadDwgFile("c:\temp\test.dwg",
FileOpenMode.OpenForReadAndReadShare, true, "");
Bitmap thumbNail = OpenDb.ThumbnailBitmap;
if (thumbNail == null)
{
//
}
else
{
//
}
}

Leave a Reply