Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Convert String to Stream correctly for DisplayLayout.Load()
posted

Hey,

 

I've a problem: I saved a gridlayout in a database as string. Then I want to load the layout again from the database. The load-function works for files and streams, so I tried to convert my string into a stream, but everytime I get the exception, that the stream has no correct binary format.

 

I've tried:

       System.IO.TextReader tr = new StringReader(dr["layout"].ToString());
       byte[] a = System.Text.Encoding.Unicode.GetBytes(tr.ReadToEnd());
       System.IO.MemoryStream memStream = new System.IO.MemoryStream(a);
       this.ultraGrid1.DisplayLayout.Load(memStream);

and also:

       System.IO.TextReader tr = new StringReader(dr["layout"].ToString());
       System.IO.MemoryStream memStream = new System.IO.MemoryStream();
       StreamWriter sw = new StreamWriter(memStream);
       sw.Write(tr.ReadToEnd());
       memStream.Seek(0, SeekOrigin.Begin);
       this.ultraGrid1.DisplayLayout.Load(memStream);

 

in both cases I get the exception.

 

I hope there is some help,

greetings