private void Browse_Click(object sender, EventArgs e)
{
try
{
openFileDialog1.Title = "Insert an image ";
openFileDialog1.InitialDirectory = "::{208D2C60-3AEA-1069-A2D7-08002B30309D}";
openFileDialog1.FileName = "";
openFileDialog1.Filter = "JPEG Image|*.jpg|GIF Image|*.gif|PNG Image|*.png";
openFileDialog1.Multiselect = false;
if (openFileDialog1.ShowDialog() != DialogResult.OK)
return;
fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
pictureBox1.ImageLocation = openFileDialog1.FileName;
fs.Close();
catch (Exception ex)
{
MessageBox.Show(ex + "Please");
}
}
private void CopyTo_Click(object sender, EventArgs e)
{
try
{
const string new_dir = "\\\\192.168.1.5\\Personal Pictures";
string extension = System.IO.Path.GetExtension(openFileDialog1.FileName);
string renamed_name = textBox1.Text + "" + extension;
string fName = System.IO.Path.Combine(new_dir, renamed_name);
if (File.Exists(fName))
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
File.Delete(fName);the exception display in this line
System.IO.File.Copy(openFileDialog1.FileName, fName);
string msg = string.Format("Copied {0} to {1}", openFileDialog1.FileName, fName);
MessageBox.Show(msg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex + "Error");
}
}
Guest UserPosted Nov 26, 2014, 5:43 AM
http://stackoverflow.com/questions/10431868/unlocking-image-from-picturebox