Load From File vs. Load From Stream
Posted: 30 Mar 2007, 18:35
<font color="black">Hello,
I have an application which displays dwg files. The dwg files are stored in a database and retrieved into a byte array. I create a stream from the byte array and call the LoadFromStream function. It works for the most part. However, I have found that it does not work for .dwg files saved in the 2007 format (earlier versions work okay). I did find that the file loads fine when calling LoadFromFile.
I have included some sample code:
<font color="blue">Dim </font id="blue"> sFileName <font color="blue">As String </font id="blue"> = IO.Path.Combine(<font color="blue">My</font id="blue">.Computer.FileSystem.SpecialDirectories.Desktop, <font color="maroon">"2007.dwg"</font id="maroon">)
<font color="blue">Dim </font id="blue"> abytPictureData() <font color="blue">As Byte </font id="blue"> = <font color="blue">My</font id="blue">.Computer.FileSystem.ReadAllBytes(sFileName)
mCADImage = <font color="blue">New </font id="blue"> DWG.DWGImage
<font color="green">' Load the picture data into a stream.</font id="green">
<font color="blue">Dim </font id="blue"> str <font color="blue">As </font id="blue"> System.IO.Stream = <font color="blue">New </font id="blue"> System.IO.MemoryStream(abytPictureData)
<font color="blue">With </font id="blue"> mCADImage
<font color="green">' The next line does not work on 2007 files</font id="green">
<font color="green">'.LoadFromStream(str)</font id="green">
<font color="green">' The next line does work on 2007 files</font id="green">
.LoadFromFile(sFileName)
.DrawMode = CADImport.CADDrawMode.Black
.DefaultColor = Color.White
.UseWinEllipse = <font color="blue">False</font id="blue">
<font color="blue"> End With</font id="blue">
Again, the LoadFromStream does not work for 2007 files. I look forward to your response.</font id="black">
-- James "ACE" Gayhart: If at first you don't succeed, call it Version 1.0.
I have an application which displays dwg files. The dwg files are stored in a database and retrieved into a byte array. I create a stream from the byte array and call the LoadFromStream function. It works for the most part. However, I have found that it does not work for .dwg files saved in the 2007 format (earlier versions work okay). I did find that the file loads fine when calling LoadFromFile.
I have included some sample code:
<font color="blue">Dim </font id="blue"> sFileName <font color="blue">As String </font id="blue"> = IO.Path.Combine(<font color="blue">My</font id="blue">.Computer.FileSystem.SpecialDirectories.Desktop, <font color="maroon">"2007.dwg"</font id="maroon">)
<font color="blue">Dim </font id="blue"> abytPictureData() <font color="blue">As Byte </font id="blue"> = <font color="blue">My</font id="blue">.Computer.FileSystem.ReadAllBytes(sFileName)
mCADImage = <font color="blue">New </font id="blue"> DWG.DWGImage
<font color="green">' Load the picture data into a stream.</font id="green">
<font color="blue">Dim </font id="blue"> str <font color="blue">As </font id="blue"> System.IO.Stream = <font color="blue">New </font id="blue"> System.IO.MemoryStream(abytPictureData)
<font color="blue">With </font id="blue"> mCADImage
<font color="green">' The next line does not work on 2007 files</font id="green">
<font color="green">'.LoadFromStream(str)</font id="green">
<font color="green">' The next line does work on 2007 files</font id="green">
.LoadFromFile(sFileName)
.DrawMode = CADImport.CADDrawMode.Black
.DefaultColor = Color.White
.UseWinEllipse = <font color="blue">False</font id="blue">
<font color="blue"> End With</font id="blue">
Again, the LoadFromStream does not work for 2007 files. I look forward to your response.</font id="black">
-- James "ACE" Gayhart: If at first you don't succeed, call it Version 1.0.