How to load , rename and save image in a folder in c#

02 Apr
private void Load_Click(object sender, EventArgs e)
openFD.Title = "Insert an image ";
openFD.InitialDirectory = "c:";
openFD.FileName = "";
openFD.Filter = "JPEG Image|*.jpg|GIF Image|*.gif|PNG Image|*.png";
openFD.Multiselect = false;
if (openFD.ShowDialog() != DialogResult.OK)

//display image in pic box
pictureBox1.ImageLocation = openFD.FileName;


private void Copy_Click(object sender, EventArgs e)
const string new_dir = @"C:\Users\Public\Pictures\Sample Pictures\";
string extension = System.IO.Path.GetExtension(openFD.FileName);
string renamed_name = id + "" + extension;
string fName = System.IO.Path.Combine(new_dir,renamed_name );
if (File.Exists(fName))
System.IO.File.Copy(openFD.FileName, fName);
string msg = string.Format("Copied {0} to {1}",openFD.FileName,   fName);
MessageBox.Show(msg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

Leave a comment

Posted by on April 2, 2012 in C#.Net


Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: