شكرا لك كثيرا
حاولت الاستفادة من الحصول علي قاعدة البيانات من مسار القاعدة المذكور واعوض به مكان اسم القاعدة في كود عمل نسخة احتياطية للقاعدة لكني فشلت
حيث ان هذا الكود ممتاز ولكن يجب ان نحدد اسم القاعدة
هل استطيع استبدال اسم القاعدة بالاسم الذي حصلت عليه من المسار كما ذكرته حضرتك
اتمني تعديل الكود شكرا
Try
If Conn.State = ConnectionState.Open Then Conn.Close()
If MsgBox("سوف يتم عمل نسخة احتياطية من قاعدة البيانات" & vbCrLf & "DataCopy وضعها في مسار البرنامج في المجلد", vbMsgBoxRight + vbExclamation + vbYesNo, "نسخ احتياطي") = MsgBoxResult.Yes Then
Application.DoEvents()
'اذا وجد نسخة بهذا الاسم يمسحها
If IO.File.Exists(Application.StartupPath & "\Compact.mdb") Then
IO.File.Delete(Application.StartupPath & "\Compact.mdb")
Dim sr As New IO.FileStream(CopyFrom, IO.FileMode.Open)
Dim sw As New IO.FileStream(CopyTo, IO.FileMode.Create)
Dim len As Long = sr.Length - 1
For i As Long = 0 To len
sw.WriteByte(sr.ReadByte)
If i Mod 1000 = 0 Then
Application.DoEvents()
ProgressBar1.Value = i * 100 / len
End If
Next
'كود البحث عن قواعد البيانات لغاية قبل شهر من تاريخ اليوم ويقوم بحذفها مع ترك اخر قاعدتين بتاريخ قبل يوم
Dim DAddDays As DateTime = GregorianDTF.Calendar.AddDays(DateTime.Today, -1)
Dim DAddMonths As DateTime = GregorianDTF.Calendar.AddMonths(DateTime.Today, -3)
Dim D_AddDays As String = DAddDays.ToString("dd-MM-yyyy", GregorianDTF)
Dim D_AddMonths As String = DAddMonths.ToString("dd-MM-yyyy", GregorianDTF)
Do Until D_AddMonths = D_AddDays
If IO.File.Exists(Application.StartupPath & "\DataCopy\" & D_AddMonths & ".mdb") = True Then
Kill(Application.StartupPath & "\DataCopy\" & D_AddMonths & ".mdb")
End If
'
Dim file As String = "C:\Users\Admin\Desktop\NewFolder\database1.mdb"
Dim result As String
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetFullPath(file) ' C:\Users\Admin\Desktop\NewFolder\database1.mdb
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetPathRoot(file) ' C:\
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetDirectoryName(file) ' C:\Users\Admin\Desktop\NewFolder
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetFileName(file) ' database1.mdb
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetFileNameWithoutExtension(file) ' database1
'-----------------------------------------------------------------------------------------------------
result = IO.Path.GetExtension(file) ' .mdb
'-----------------------------------------------------------------------------------------------------