首页 新闻 会员 周边 捐助

"Out of Memory" exception

0
悬赏园豆:100 [已关闭问题]
I got "Out of memory" exception when load an ".ico" file use <FONT face=Verdana>System.Drawing.Image.FromFile, <BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Image.FromFile(sFilePath,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">);</SPAN></DIV>but don't get any exception when load a ".jpg" file, and there are same permission settings for these files. I found a&nbsp;<A href="http://jcapka.blogspot.com/2006/06/imagefromfile-gives-out-of-memory.html"><FONT color=#0000ff>post</FONT></A> which said the exception caused by it doesn't have <FONT face=Verdana>sufficient permission. :(<BR></FONT><BR>And I still got "Paramter is not vaild" exception when load the ico use Image.FromStream. <BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">FileStream&nbsp;fs&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;FileStream(sFilePath,&nbsp;FileMode.Open,&nbsp;FileAccess.Read);<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>Image&nbsp;img&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Image.FromStream(fs,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">);</SPAN></DIV>I'm confused, the codes seem work on another PC. :(<BR><BR>Who knows what am i doing wrong?</FONT>
蒜头的主页 蒜头 | 初学一级 | 园豆:100
提问于:2008-03-18 11:00
< >
分享
其他回答(1)
0
I've met a similiar problem, I can load a jpg file, but can't save it to file, or there is a "OutOfMemoryException". What I suggest you to do is to check if the ".ico" file is valid, open it with other software.
deerchao | 园豆:8367 (大侠五级) | 2008-03-18 11:51
0
Maybe you can try to use Icon.ctor(string) to load this file to an Icon instance. Than use Bitmap.ctor(Icon) to convert the object to an Image object.
Colin Han | 园豆:3041 (老鸟四级) | 2008-03-18 13:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册