0
尝试保存图像时遇到GDI错误。我看过很多解决方案,似乎没有人回答这个问题。我创建了一个简单的加载和保存按钮的窗体。在GDI中发生了一般性错误+简单读取并保存
加载使用流读取,我正在保存到一个新的文件名。测试创建工作不是权限。文件abctest.jpg用0字节创建。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CheckImageInUse
{
public partial class Form1 : Form
{
Bitmap originalImage = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (var fs = File.OpenRead(@"c:\images\DSC_0005.JPG"))
{
this.originalImage = new Bitmap(fs);
}
}
private void button2_Click(object sender, EventArgs e)
{
using (File.Create(@"c:\images\testcreate.txt"))
{ }
this.originalImage.Save(@"c:\images\abctest.jpg");
}
}
}