开发者

Silverlight 4.0: How to determine the file size of an object in MemoryStream

byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0,
imageBytes.开发者_如何转开发Length);

How will I determine its file size of an image?


You should be able to determine the size of the stream pretty easy.

MemoryStream ms = new MemoryStream();
int length = ms.Length;

length is now the length of the stream in bytes. This bytenumber should also be the size of any file you would store that contained only this stream.

Edit:

If you mean in pixels you could use something like:

Image img = Image.FromStream(ms);
int width = img.Width;
int height = img.Height;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜