راه های زیادی برای لود کردن فایل به bytearray وجود دارد .که میتوان از آبجکت ADODB.Stream استفاده نمود.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("dbo_WATER_FILES", dbOpenDynaset, dbSeeChanges)
rst.Edit
Dim strm As Object
Set strm = CreateObject("ADODB.Stream")
strm.Type = 1
strm.Open
strm.LoadFromFile "C:\test.jpg"
rst.Fields("Binary_File").Value = strm.Read 'FileData
strm.Close
rst.Update
برای برگشت باینری به یک فایل :
With CreateObject("ADODB.Stream")
.Type = 1
.Open
.Write rst.Fields("Binary_File").Value
.SaveToFile "C:\testcopy.jpg", 2
.Close
End With
تبدیل باینری به تکست یا تکست به باینری هم از همین آبجکت
می توان بهره برد.
| Field Name | Description |
|---|
| FileData | The file itself is stored in this field. |
| FileFlags | Reserved for future use. |
| FileName | The name of the file in the attachment field. |
| FileTimeStamp | Reserved for future use. |
| FileType | The file extension of the file in the attachment field. |
| FileURL | The URL for the file for a linked SharePoint list. Will be Null for local Access tables. |