Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to copy the mdf file and this mdf file is currently Used in my application. when i am trying to copy mdf file then it will display error currenly file used in other process i have tried to dispose the connection but this also not helpful for me please help me.

What I have tried:

//Here i am Disconnecting the SQL connection
connection.Close();
SqlConnection.ClearPool(connection);
connection.Dispose();
connection.Dispose();

//Here i am trying to copy but not success
System.IO.File.Copy(DownloadmdfPath, UploadmdfPath, true);
Posted
Updated 14-Sep-17 0:36am

1 solution

A quick How to copy mdf file using C# - Google Search[^] has lots of answers...

Whilst not in English, his code is easy to follow and answers your question: How to copy database in sql server using c# net - YouTube[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900