Copy mdf file and use it in run time
After I copy mdf file (and his log file) I tries to Insert data. I receive the following message:
"An attempt to attach an auto-named database for file [fileName].mdf failed. A database with the same name exists, or开发者_开发知识库 specified file cannot be opened, or it is located on UNC share.
When I copied the file manual everything worked normally. Is it correct the order File.Copy leaves the file engaged?
Make sure you don't have a connection open to the mdf file when you copy it. This might be related to there being only one lock file for the two copies.
The solution was much more simple. I forgot to close the file
fileStream.Close();
精彩评论