如何在Windows应用程序的本地驱动器中存储图像 [英] How to store Image In Local Drive in windows application

查看:93
本文介绍了如何在Windows应用程序的本地驱动器中存储图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用OpenFileDialog上传员工的照片,并在图片框中显示照片.我希望照片应存储在本地系统中,例如在"E:\"驱动器中.以下是我的照片上传代码.

In my application i upload photo of employee using OpenFileDialog and display photo in picture box. i want photo should be store in local system for example in "E:\" drive.below is my code of photo upload.

private void btnphotoupload_Click(object sender, EventArgs e)
        {
            // upload image and display in picture box

            OpenFileDialog open = new OpenFileDialog();
            // image filters
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
            {
                // display image in picture box
                pictureBox1.Image = new Bitmap(open.FileName);

                // image file path
                // textBox1.Text = open.FileName;

            }
           // var = open.FileName;
            Data.imagelocation = open.FileName;
           

        }

推荐答案

不是很确定您的问题是什么,但是可以使用SaveFileDialog:
http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx#Y2964 [ ^ ]
并保存图片:
http://msdn.microsoft.com/en-us/library/9t4syfhh.aspx [ ^ ]
Not really sure what your issue is but SaveFileDialog could be used:
http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx#Y2964[^]
and saving the picture:
http://msdn.microsoft.com/en-us/library/9t4syfhh.aspx[^]


查看此:
private void button1_Click(object sender, EventArgs e)
{
   pictureBox1.Image.Save("C:\\Temp\\Test.bmp");
}




试试这个,

Hi,

try this,

private void btnphotoupload_Click(object sender, EventArgs e)
    {
        // upload image and display in picture box

        OpenFileDialog open = new OpenFileDialog();
        // image filters
        open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
        if (open.ShowDialog() == DialogResult.OK)
        {
            BitMap btMap = new Bitmap(open.FileName);

            // display image in picture box
            pictureBox1.Image = btMap;
            
           //Save the image in new location
           btMap.Save(@"E:\Images\Image.jgp");
            
        }
       // var = open.FileName;
        Data.imagelocation = open.FileName;
    }



希望它能起作用



Hope it works


这篇关于如何在Windows应用程序的本地驱动器中存储图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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