The requested operation cannot be performed on a file with a user-mapped section open.

I am trying to perform a simple File.Copy()

        string _originalFile = "Lapdesk.Websites/Files/Lapdesk_Quote_Original.xls";
        string _destFile = "Lapdesk.Websites/Files/Lapdesk_Quote.xls";
       //Generatate copy of original and modify.
       File.Copy(_originalFile, _destFile, true);

When the above mentioned error is generated.  The files are not open and no background proceses are running that can access them
Who is Participating?
galar71Connect With a Mentor Commented:
Have you checked if you have all the appropriate permissions for the folder and the file?
I would also make sure that no other program is using the file you are trying to copy. Worst case, log off and log back on, and retry (as long as it's not on a network and somebody else might have it open). This might also do the trick.

I'm not entirely certain why you get the error, but I believe it's a locking or permission issue, albeit a somewhat obscure one.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.