Answers for "save image to specific folder in C#"

C#
1

save image to specific folder in C#

OpenFileDialog opFile = new OpenFileDialog();
opFile.Title = "Select a Image";
opFile.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";

string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\ProImages\"; // <---
if (Directory.Exists(appPath) == false)                                              // <---
{                                                                                    // <---
    Directory.CreateDirectory(appPath);                                              // <---
}                                                                                    // <---

if (opFile.ShowDialog() == DialogResult.OK)
{
    try
    {
        string iName = opFile.SafeFileName;   // <---
        string filepath = opFile.FileName;    // <---
        File.Copy(filepath, appPath + iName); // <---
        picProduct.Image = new Bitmap(opFile.OpenFile());
    }
    catch (Exception exp)
    {
        MessageBox.Show("Unable to open file " + exp.Message);
    }
}
else
{
    opFile.Dispose();
}
Posted by: Guest on January-05-2021
-1

how to get image from resource folder in c#

textBox1.Text = Directory.GetCurrentDirectory() + "\\Resources\\10.PNG";
Posted by: Guest on December-05-2020

Code answers related to "save image to specific folder in C#"

C# Answers by Framework

Browse Popular Code Answers by Language