hello,
i have a application, with sql database, now i want to backup every week, so i have code a but it gives error:
"The process cannot access the file 'C:\Users\yogeishh\Desktop\Restaurant-Stock-Management-System\Restaurant-Stock-Management-System\DataBase\RestaurantStockDataBase.mdf' because it is being used by another process."
can anybuddy solve this error??
my code is :: "
Private Sub btnCreateBackUpOfSetting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateBackUpOfSetting.Click
'Try
Dim fulfilename As String
fulfilename = "C:\Users\yogeishh\Desktop\Restaurant-Stock-Management-System\Restaurant-Stock-Management-System\DataBase\RestaurantStockDataBase.mdf"
Dim sfd As New SaveFileDialog
sfd.FileName = "Restaurant Stock Backup"
' sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
sfd.Title = "Select Save Location..."
sfd.Filter = "SQL Server 2005 Files (*.mdf)|*.mdf"
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.CopyFile(fulfilename, sfd.FileName)
Dim fileDetail As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(sfd.FileName)
fileDetail.IsReadOnly = True
'fileDetail.Attributes = fileDetail.Attributes Or IO.FileAttributes.ReadOnly
MsgBox("Backup is Created...")
End If
'Catch ex As Exception
' MsgBox(ex.Message)
'End Try
End Sub
Private Sub btnRestoreBackUpOfSetting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestoreBackUpOfSetting.Click
'Try
Dim fulfilename As String
fulfilename = "C:\Users\yogeishh\Desktop\Restaurant-Stock-Management-System\Restaurant-Stock-Management-System\DataBase\RestaurantStockDataBase.mdf"
Dim ofd As New OpenFileDialog
ofd.FileName = ""
ofd.Filter = "SQL Server 2005 Files (*.mdf)|*.mdf"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.DeleteFile("C:\Users\yogeishh\Desktop\Restaurant-Stock-Management-System\Restaurant-Stock-Management-System\DataBase\RestaurantStockDataBase.mdf")
My.Computer.FileSystem.CopyFile(ofd.FileName, fulfilename)
MsgBox("Backup is Restored...")
End If
'Catch ex As Exception
' MsgBox(ex.Message)
'End Try
End Sub
plz solve this problem
thnks