Home > DeveloperSection > Forums > it is being by another process when copy file from local disk to folder in domain network why
ahmed salah
ahmed salah

Total Post:12

Posted on    November-05-2014 4:52 AM

 C# C# 

 2 Reply(s)
 1105  View(s)
Rate this:
Hi guys i have problem in my code when i try to copy image jpg from local disk in any place to network path DOMAIN
it give me error the process cannot access the file it using by another process file

why this message show

and how to solve.the error show in line delete of file

my code as below

private void button11_Click_1(object sender, EventArgs e)

openFileDialog1.Title = "Insert an image ";
openFileDialog1.InitialDirectory = "c:";
openFileDialog1.FileName = "";
openFileDialog1.Filter = "JPEG Image|*.jpg|GIF Image|*.gif|PNG Image|*.png";
openFileDialog1.Multiselect = false;
if (openFileDialog1.ShowDialog() != DialogResult.OK)
pictureBox2.ImageLocation = openFileDialog1.FileName;

private void button12_Click_4(object sender, EventArgs e)
const string new_dir = "\\\\\\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))
File.Delete(fName);this line give error
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);

How to solve the error
if possible help me

John Smith

Total Post:102

Posted on    November-05-2014 11:10 AM

Looks like your file being accessed by some other part of your code....

Modified On Nov-05-2014 11:13:52 AM

Corey lean
Corey lean

Total Post:1

Posted on    September-04-2017 10:53 AM

While copying files from old pc to new one, I was getting this error quite a lot. Whatever the time being, the error said the same. I didn’t knew what exactly the problem is. After searching a lot and reading blogs I found people suggesting to use GS Richcopy 360. I also tried it and it worked for me very well. It helped me a lot, using this I can also automate my file transfer. Try it, hope this comment helps someone!

Don't want to miss updates? Please click the below button!

Follow MindStick