C#程序图像保存有关问题
C#程序图像保存问题
这是一个保存图像的代码,关闭调试时候总是提示路径不合法,求指导。
private void menuItem3_Click(object sender, EventArgs e)
{
string str;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "BMP文件(*.BMP)|*.BMP|All File(*.*)|*.*";
saveFileDialog1.ShowDialog();
str = saveFileDialog1.FileName;
pictureBox1.Image.Save(str);
}
问题出在pictureBox1.Image.Save(str);这块,截图上传好慢,只好粘贴文字过了给大家看,望各位指导。
------解决方案--------------------
//图像保存函数
private void SaveImage()
{
try
{
SaveFileDialog sfd.Filter = "保存(*.bmp)
------解决方案--------------------
*.bmp
------解决方案--------------------
(*.jpg)
------解决方案--------------------
*.jpg
------解决方案--------------------
(*.png)
------解决方案--------------------
*.png";
sfd.Title = "保存";
sfd.ShowHelp = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
Bitmap temp = (Bitmap)picBox.Image;
temp.Save(sfd.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
这是一个保存图像的代码,关闭调试时候总是提示路径不合法,求指导。
private void menuItem3_Click(object sender, EventArgs e)
{
string str;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "BMP文件(*.BMP)|*.BMP|All File(*.*)|*.*";
saveFileDialog1.ShowDialog();
str = saveFileDialog1.FileName;
pictureBox1.Image.Save(str);
}
问题出在pictureBox1.Image.Save(str);这块,截图上传好慢,只好粘贴文字过了给大家看,望各位指导。
C#
------解决方案--------------------
//图像保存函数
private void SaveImage()
{
try
{
SaveFileDialog sfd.Filter = "保存(*.bmp)
------解决方案--------------------
*.bmp
------解决方案--------------------
(*.jpg)
------解决方案--------------------
*.jpg
------解决方案--------------------
(*.png)
------解决方案--------------------
*.png";
sfd.Title = "保存";
sfd.ShowHelp = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
Bitmap temp = (Bitmap)picBox.Image;
temp.Save(sfd.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}