c# - Cannot open backup device - Operating system error 3 -
i have section in project webmaster can create , download occasional database backups. here code
[httppost] public actionresult backup(databasebackupviewmodel model) { var constr = system.web.configuration.webconfigurationmanager.appsettings["constr"]; var backupfolder = system.web.httpcontext.current.server.mappath("\\content\\db-backup\\"); var backupfilename = string.format("bkp-{0}-{1}.bak", datetime.now.tostring("yyyy-mm-dd"), datetime.now.ticks.tostring(cultureinfo.invariantculture)); using (var connection = new sqlconnection(constr)) { var query = string.format("backup database dbname disk='{0}'", backupfolder + backupfilename); using (var command = new sqlcommand(query, connection)) { connection.open(); command.executenonquery(); //save database. var bkp = new databasebackuplog { backupid = guid.newguid(), backuptitle = model.title, backupfilename = backupfilename, backupdate = datetime.now }; _service = new databaseservice(); _service.create(bkp); } } return view(model); }
the above code works great @ local, when trying backup database on remote, getting following error:
cannot open backup device... operating system error 3(the system cannot find path specified.). backup database terminating abnormally.
i double checked - folder @ right place. name of folder has no spelling mistake or anything. granted full permission user accounts folder hosting control panel.
nothing works! have no idea what's going wrong. please help
thank in advance
Comments
Post a Comment