1

In my application if the application installed for the first time on client machine, the application will restore there database if the database dose not exsist .. I included the .bak database according This artical :

  • Create a folder under the app in VS name e.g. "datafiles"
  • Add all files to that folder using Add as link in the dialog box after selecting Add existing item on the folder
  • Mark all files as Copy if newer (Copy to output directory property)
  • Make sure the build action is content

when I publish the files put in publish folder and be a part of the application installation

Until now every thing work fine..

The probelm is when I trieng to restore the database from my code, the VS say :

"Cannot open backup device, Operating system error 5 (Access is denied.)."

I tried to run the VS as administrator but this does not make any change..

Please can any one help me to solve this issue

Thanks in advance

Abdusalam

Community
  • 1
  • 1
Abdulsalam Elsharif
  • 4,773
  • 7
  • 32
  • 66
  • Is the problem when SQL Server is trying restore the database? If so, move the `.bak` file to the default SQL Server backup directory, and then try to restore the back up. – StarPilot Apr 14 '15 at 22:01
  • Yes, the problem happen in the restore step and the error message "Can not open .bak file, access denied", I need to include the .bak file with WPF click-once deployment for installation ! – Abdulsalam Elsharif Apr 14 '15 at 22:06

0 Answers0