1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| *****************************************************************
If CONNECT_AccessBD Then
AccessRst.Open "select * from IDENTITY2 ", AccessCn, adOpenStatic
Do While Not AccessRst.EOF
MAX_PATH = 260
BLOCK_SIZE = 100000
Set fso = CreateObject("Scripting.FileSystemObject")
'*******************************
'*** IMPORTATION DE LA PHOTO ***
'*******************************
' Get a temporary file name.
file_name = TemporaryFileName()
' Open the file.
file_num = FreeFile
Open file_name For Binary As #file_num
' Copy the data into the file.
file_length = AccessRst.Fields("foto").ActualSize
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
'get all chunks and write then to a temp file
For block_num = 1 To num_blocks
bytes() = AccessRst.Fields("foto").GetChunk(BLOCK_SIZE)
Put #file_num, , bytes()
Next block_num
If left_over > 0 Then
bytes() = AccessRst.Fields("foto").GetChunk(left_over)
Put #file_num, , bytes()
End If
Close #file_num
PathPhoto = "C:\ImgCRU\Ph\" & AccessRst!ordinal_number & ".jpg"
fso.CopyFile file_name, PathPhoto
MsgBox ("Extraction achevée...")
End If
**************************************************************** |
Partager