BitmapImage: Accessing closed StreamSource
问题 I'm using the following code trying to convert my BitmapImage to a byte[] so I can save it in my MS SQL Database. public static byte[] BufferFromImage(BitmapImage img) { if (img == null) return null; byte[] result = null; using (Stream stream = img.StreamSource) { if (stream != null && stream.Length > 0) { using (BinaryReader br = new BinaryReader(stream)) { result = br.ReadBytes((int)(stream.Length)); } } } return result; } Sadly this doesn't work as img.StreamSource is disposed when I try