Reading from memory stream to string

If you’d checked the results of stream.Read, you’d have seen that it hadn’t read anything – because you haven’t rewound the stream. (You could do this with stream.Position = 0;.) However, it’s easier to just call ToArray: settingsString = LocalEncoding.GetString(stream.ToArray()); (You’ll need to change the type of stream from Stream to MemoryStream, but that’s okay … Read more

XML Serialization and namespace prefixes

To control the namespace alias, use XmlSerializerNamespaces. [XmlRoot(“Node”, Namespace=”http://flibble”)] public class MyType { [XmlElement(“childNode”)] public string Value { get; set; } } static class Program { static void Main() { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add(“myNamespace”, “http://flibble”); XmlSerializer xser = new XmlSerializer(typeof(MyType)); xser.Serialize(Console.Out, new MyType(), ns); } } If you need to change the namespace … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)