تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كيف يُمكن أدخال أداة ال Progress Bar للتزامن مع نسخ قاعدة بيانات الأكسس؟
#4
وظيفة الكود يظهر نافذة النسخ أو النقل الخاصة بالنظام والذي هو يمتلك تزامن عملية النقل أو النسخ.

جرب هذا


https://stackoverflow.com/a/34939234
كود :
Dim [sourceFile] As String = Application.StartupPath & "/A18.accdb"
Dim [targetFile] As String = "D:\Backup\BupDB-" & Now.Date.ToString("dd-MM-yyyy") & "A18.accdb"

CopyFileWithProgress([sourceFile], [targetFile], Me.ProgressBar1)
كود :
Private Sub CopyFileWithProgress([sourceFile] As String, [targetFile] As String, [progress] As ProgressBar)
   'Create the file stream for the source file
   Dim streamRead As New System.IO.FileStream([sourceFile], System.IO.FileMode.Open)
   'Create the file stream for the destination file
   Dim streamWrite As New System.IO.FileStream([targetFile], System.IO.FileMode.Create)
   'Determine the size in bytes of the source file (-1 as our position starts at 0)
   Dim lngLen As Long = streamRead.Length - 1
   Dim byteBuffer(1048576) As Byte   'our stream buffer
   Dim intBytesRead As Integer    'number of bytes read

   While streamRead.Position < lngLen    'keep streaming until EOF
       'Read from the Source
       intBytesRead = (streamRead.Read(byteBuffer, 0, 1048576))
       'Write to the Target
       streamWrite.Write(byteBuffer, 0, intBytesRead)
       'Display the progress
       [progress].Value = CInt(streamRead.Position / lngLen * 100)
       Application.DoEvents()    'do it
   End While

   'Clean up
   streamWrite.Flush()
   streamWrite.Close()
   streamRead.Close()
End Sub
الرد }}}
تم الشكر بواسطة: Hazem1 , asemshahen5 , elgokr , princelovelorn , princelovelorn


الردود في هذا الموضوع
RE: كيف يُمكن أدخال أداة ال Progress Bar للتزامن مع نسخ قاعدة بيانات الأكسس؟ - بواسطة rnmr - 04-10-18, 10:01 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم