参数无效。图像保存C# [英] Parameter is not valid. Image save C#

查看:105
本文介绍了参数无效。图像保存C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

try
{

    if (File.Exists(textBox1.Text))
    {
        pictureBox2.Image.Dispose();
        File.Delete(textBox1.Text);


        fname = TxtNameMada.Text + ".jpg";
        string folder = @"E:\Images\" + comboBox1.Text + "";
        pathstring = Path.Combine(folder, fname);

        using (Image a = pictureBox2.Image)
        {
            a.Save(pathstring);
            a.Dispose();
        }
    }
    else
    {
        fname = TxtNameMada.Text + ".jpg";
        string folder = @"E:\Images\" + comboBox1.Text + "";
        pathstring = Path.Combine(folder, fname);
        Image a = pictureBox2.Image;
        a.Save(pathstring);
        a.Dispose();
    }
}
catch (Exception ex)
{

    MessageBox.Show(ex.Message + "  ufff");
}





我尝试过:



我正在尝试这个代码块但我已经显示此错误请帮我修复我的错误



i需要删除路径才能保存然后我想保存新路径图像



What I have tried:

I am trying this code block but I have displayed this error please help me to fix my error

i need delete path before saving then i want to save new path image

推荐答案

尝试在保存图像时指定格式:

Try specifying the format when you save the image:
a.Save(paststring, ImageFormat.Jpeg);



如果这没有用,请使用调试器找出路径字符串中的确切内容,然后告诉我们确切地知道异常发生的地点和时间。


If that doesn't help, use the debugger to find out exactly what is in the path string, and tell us exactly where and when the exception occurs.


这篇关于参数无效。图像保存C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆