C#:如何将面板1作为图像保存到特定文件夹? [英] C# :how to save panel 1 as image to specific folder ?

查看:47
本文介绍了C#:如何将面板1作为图像保存到特定文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的代码,如何修改以将图像保存到特定文件夹?



我尝试过:



Below this is my code, and how can i modified to save the image to the specific folder ?

What I have tried:

<pre> using (Bitmap graphicSurface = new Bitmap(panel1.Width, panel1.Height))
            {
                using (StreamWriter bitmapWriter = new StreamWriter("TEST.JPEG"))
                {
                    panel1.DrawToBitmap(graphicSurface, new Rectangle(0, 0, panel1.Width, panel1.Height));
                    graphicSurface.Save(bitmapWriter.BaseStream, ImageFormat.Jpeg);
                }
            }
        }

推荐答案

更改此:

Change this:
new StreamWriter("TEST.JPEG")



对此:


To this:

new StreamWriter("[your desired path]\TEST.JPEG")



请注意,要传递的参数是PATH,而不是FILE ......

StreamWriter构造函数(String)(System.IO) [ ^ ]


这篇关于C#:如何将面板1作为图像保存到特定文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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