Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic load_diagram exeption: Unsupported file format (Read 2868 times)
hans
Junior Member
**
Offline


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
load_diagram exeption: Unsupported file format
Dec 28th, 2012 at 10:42am
Print Post  
I have a problem with saving and loading a diagram to  and from stream.
I use this code:
saving the diagram          
     string SaveDiagram = _EditReference + ".dgr";
     stream = new MemoryStream();
     DiagramView1.Diagram.SaveToStream(stream);
     imageBytes = stream.GetBuffer();
     stream.Seek(0, SeekOrigin.Begin);
     CloudBlockBlob blob3 = BlobContainer.GetBlockBlobReference(SaveDiagram);
     blob3.UploadFromStream(stream);
     stream.Close();

loading the diagram
     CloudBlockBlob blob = BlobContainer.GetBlockBlobReference(SavedDiagram);
     blob.FetchAttributes();
     MemoryStream m = new MemoryStream();
     blob.DownloadToStream(m);
     DiagramView1.Diagram.LoadFromStream(m);
results in: load_diagram exeption: Unsupported file format

When I first download the blob to a file and then loadFromFile it works well.
Is loadFromStream not supported for memorystreams ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: load_diagram exeption: Unsupported file format
Reply #1 - Dec 28th, 2012 at 10:57am
Print Post  
Diagram's LoadFromStream method starts reading from the stream's current position, and blob.DownloadToStream(m) might be moving it to the end. Try seeking to the stream's origin before calling LoadFromStream.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
hans
Junior Member
**
Offline


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
Re: load_diagram exeption: Unsupported file format
Reply #2 - Dec 29th, 2012 at 10:24am
Print Post  
Thanks Stoyan,

It helped.
I always get great help from you.

Thanks again.
Hans
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint