//////////////////////////////////////////////////
// //
// 文件转换为Blob数据函数 //
// 参数: file1:文件名,blob1:blob类型数据 //
// 返回值: 1表示成功 -1表示失败 //
// By Liu Chuanhan 99.8.10 //
// //
//////////////////////////////////////////////////
integer li_FileNum,loops,i
long flen, bytes_read
blob b
SetPointer(HourGlass!)
blob1 = blob('')
if not FileExists(file1) then
// MessageBox("错误","文件 '"+file1+"' 不存在")
return -1
end if
flen = FileLength(file1)
li_FileNum = FileOpen(file1, StreamMode!, Read!, Shared! )
if li_FileNum = -1 then
// messagebox('操作系统错误','无法打开文件!')
return -1
end if
if flen > 32765 then
if Mod(flen, 32765) = 0 then loops = flen/32765 else loops = (flen/32765) + 1
else
loops = 1
end if
for i = 1 to loops
bytes_read = FileRead(li_FileNum,b)
// w_mdi.setmicrohelp('read ' + file1 + ':' + string(i/loops))
blob1 = blob1 + b
next
FileClose(li_FileNum)
SetPointer(Arrow!)
return 1
// //
// 文件转换为Blob数据函数 //
// 参数: file1:文件名,blob1:blob类型数据 //
// 返回值: 1表示成功 -1表示失败 //
// By Liu Chuanhan 99.8.10 //
// //
//////////////////////////////////////////////////
integer li_FileNum,loops,i
long flen, bytes_read
blob b
SetPointer(HourGlass!)
blob1 = blob('')
if not FileExists(file1) then
// MessageBox("错误","文件 '"+file1+"' 不存在")
return -1
end if
flen = FileLength(file1)
li_FileNum = FileOpen(file1, StreamMode!, Read!, Shared! )
if li_FileNum = -1 then
// messagebox('操作系统错误','无法打开文件!')
return -1
end if
if flen > 32765 then
if Mod(flen, 32765) = 0 then loops = flen/32765 else loops = (flen/32765) + 1
else
loops = 1
end if
for i = 1 to loops
bytes_read = FileRead(li_FileNum,b)
// w_mdi.setmicrohelp('read ' + file1 + ':' + string(i/loops))
blob1 = blob1 + b
next
FileClose(li_FileNum)
SetPointer(Arrow!)
return 1

2597

被折叠的 条评论
为什么被折叠?



