【发布时间】:2013-04-03 08:55:46
【问题描述】:
我正在尝试在图片框中显示icon file。我正在使用此代码来设置图像。
pictureBox1.Image = new Icon(openFileDialog.FileName, new Size(48, 48)).ToBitmap();
但我遇到了这个异常。
System.ArgumentOutOfRangeException: Requested range extends past the end of the array.
at System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
at System.Runtime.InteropServices.Marshal.Copy(Byte[] source, Int32 startIndex, IntPtr destination, Int32 length)
at System.Drawing.Icon.ToBitmap()
如何解决这个问题?
谢谢。
【问题讨论】:
标签: c# icons picturebox