Saving drawing with 'SaveToStream' creates broken file

Discuss and ask questions about CAD .NET library.

Moderators: admin, support, SDS

Post Reply
StefanChrist
Posts: 15
Joined: 06 Jul 2018, 10:52

Saving drawing with 'SaveToStream' creates broken file

Post by StefanChrist » 22 Oct 2018, 10:39

Hello Support,

I am using the SaveToStream function to write a drawing into a stream, which is stored in a database. It is also possible to create a DWG file with this data. Sometimes the exported file seems to be corrupt, at least TrueView shows a message when opening those files:

"Errors were detected in the drawing. The file cannot be opened without being recovered."

Is there a way to check what is causing those issues?

I am sorry that I cannot attach the generated file to this thread but I could mail it to you if this would help you.

Thank you,
Stefan

support
Posts: 2824
Joined: 30 Mar 2005, 11:36
Contact:

Re: Saving drawing with 'SaveToStream' creates broken file

Post by support » 22 Oct 2018, 14:52

Hello Stephan,

Please post a code which generates a DWG file from a stream, we will check it.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

StefanChrist
Posts: 15
Joined: 06 Jul 2018, 10:52

Re: Saving drawing with 'SaveToStream' creates broken file

Post by StefanChrist » 23 Oct 2018, 08:38

Hello Mikhail,

this is the codes that stores the DWG file:

Code: Select all

Dim s = New System.IO.MemoryStream
CADtoDWG.SaveToStream(Drawing, s)
      Dim fs As New FileStream("C:\TMP\" & Date.Now.ToString("yyyy-MM-dd") & ".dwg", FileMode.Create)
      s.WriteTo(fs)
      fs.Close()
      s.Close()
Thank you.

support
Posts: 2824
Joined: 30 Mar 2005, 11:36
Contact:

Re: Saving drawing with 'SaveToStream' creates broken file

Post by support » 23 Oct 2018, 18:25

Hello Stefan,

The code is correct. Could you please mail us the drawing which you save through a MemoryStream and get a corrupted DWG file?

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply