本帖最后由 fenger8293 于 2009-07-07 19:57:36 编辑

解决方案 »

  1.   


    pictureBox1.Image = null;
        string fileFullPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\dumpFile\\" + selCombo.SelectedItem.ToString();
        if (System.IO.File.Exists(fileFullPath))
            {
                Stream inputStream =File.OpenRead(fileFullPath);
        Bitmap bitmap  = new Bitmap(inputStream); 
        pictureBox1.Image = bitmap;
            }
    try..
      

  2.   

    byte[] pData = readSmallFile(fileFullPath);
    Stream stream = new MemoryStream(pData);
    Bitmap bitmap  = new Bitmap(pData); Bitmap构造函数可以接受byte[]吗?有一种可能,你直接把这个byte[]的Stream传给Bitmap的构造函数,它会认为这个Stream就是Bitmap格式的,所以内部把jpg格式当成bmp来解析,所以出错了。
      

  3.   

    检查你的 readSmallFile里的代码 ...可能获取byte时候错误..
    最简单的办法byte[] pData =System.IO.File.ReadAllBytes(fileFullPath);
      

  4.   

    当然2048*1538的图片只有500多K肯定不是BMP,我刚才说jpg也不一定是jpg,只是一个例子。
      

  5.   

    OutOfMemoryException是.net在申请托管内存的时候而有没有足够的内存空间造成的。
    这个异常应用程序无法捕获。
    还有一个就是楼主使用了非托管资源但是没有及时释放~
    stream  最后需要call
    stream.close();
    stream.Dispose();方法释放非托管资源或者是
    using(Stream inputStream =File.OpenRead(fileFullPath))
    {
      ....
      inputStream.close();
    }