ذخیره سازی بایت های فایل در دیتابیس و بازیابی فایل و ذخیره آن در دیسک - 10

در این ویدیو نحوه استخراج بایت های فایل از جدول BinaryData و بازسازی فایل در دیسک توضیح داده می شه...فلوچارت الگوریتم استخراج بایت های فایل از جدول BinaryData ExtractBytes(FileEntry As File) As Byte() Dim QUERY As ObjectQuery(Of BinaryData) QUERY = Entity.CreateQuery(Of BinaryData)( _ "SELECT VALUE DataEntry FROM BinaryDatas As DataEntry WHERE DataEntry.FileID = @ID", _ New ObjectParameter("ID", FileEntry.ID)) If QUERY.Count = 0 Then Return New Byte() {} Dim FileBytes() As Byte = {} 'Debug.Print("{0}", FileEntry.Length) Dim Start As Integer = 0 Dim Length As Integer = 0 Dim Unit As Short = 1024 Dim Data() As Byte = {} Dim List As New List(Of BinaryData) List = QUERY.ToList ReDim FileBytes(FileEntry.Length - 1) ' To Know FullCells... Dim FullFields As Integer = FileEntry.Length Unit 'Remaining Bytes: File.Length - (FullCells * 1024).... Dim Remain As Short = (FileEntry.Length Mod Unit) If List.Count = 1 Then Length = FileEntry.Length ElseIf List.Count > 1 Then For Index = 0 To FullFields - 1 Data = List(Index).Data Array.ConstrainedCopy(Data, 0, FileBytes, Index * Unit, Unit) Application.DoEvents() Next Index If Remain = 0 Then Return FileBytes Start = (FullFields * Unit) Length = Remain End If Data = List.Last.Data Array.ConstrainedCopy(Data, 0, FileBytes, Start, Length) Return FileBytes End Function
ویدیوهای مرتبط
ویدیوهای جدید