gf_file_from_blob(blob blob1,string file1) pb大字段生成文件方法
2014-03-17 22:38
309 查看
//////////////////////////////////////////////////
// //
// Blob数据转换为文件函数
//
// 参数: blob1:blob类型数据,file1:文件名 //
// 返回值: 1表示成功 -1表示失败
//
// //
//////////////////////////////////////////////////
integer li_FileNum,loops,i
long blen, bytes_read
blob b
SetPointer(HourGlass!)
try
if FileExists(file1) then
blen = 0
SetFileAttributes(file1,blen)
if not FileDelete(file1) then
messagebox('操作系统错误','无法进行进一步的处理!~r~n~r~n建议您妥善保存文件,然后重新启动计算机,或杀除WINWORD进程。')
return -1
end if
end if
blen = len(blob1)
li_FileNum = FileOpen(file1, StreamMode!, Write!)
if li_FileNum = -1 then return -1
if blen > 32765 then
if Mod(blen, 32765) = 0 then loops = blen/32765 else loops = (blen/32765) + 1
else
loops = 1
end if
for i = 1 to loops
b = BlobMid(blob1,(i - 1) * 32765 + 1, 32765)
bytes_read = FileWrite(li_FileNum, b)
// w_mdi.setmicrohelp('write ' + file1 + ':' + string(i/loops))
next
//w_mdi.setmicrohelp('File closed')
FileClose(li_FileNum)
SetPointer(Arrow!)
catch(throwable thab)
gf_exception("gf_file_from_blob",thab.text)
end try
return 1
// //
// Blob数据转换为文件函数
//
// 参数: blob1:blob类型数据,file1:文件名 //
// 返回值: 1表示成功 -1表示失败
//
// //
//////////////////////////////////////////////////
integer li_FileNum,loops,i
long blen, bytes_read
blob b
SetPointer(HourGlass!)
try
if FileExists(file1) then
blen = 0
SetFileAttributes(file1,blen)
if not FileDelete(file1) then
messagebox('操作系统错误','无法进行进一步的处理!~r~n~r~n建议您妥善保存文件,然后重新启动计算机,或杀除WINWORD进程。')
return -1
end if
end if
blen = len(blob1)
li_FileNum = FileOpen(file1, StreamMode!, Write!)
if li_FileNum = -1 then return -1
if blen > 32765 then
if Mod(blen, 32765) = 0 then loops = blen/32765 else loops = (blen/32765) + 1
else
loops = 1
end if
for i = 1 to loops
b = BlobMid(blob1,(i - 1) * 32765 + 1, 32765)
bytes_read = FileWrite(li_FileNum, b)
// w_mdi.setmicrohelp('write ' + file1 + ':' + string(i/loops))
next
//w_mdi.setmicrohelp('File closed')
FileClose(li_FileNum)
SetPointer(Arrow!)
catch(throwable thab)
gf_exception("gf_file_from_blob",thab.text)
end try
return 1
相关文章推荐
- gf_file_to_blob(string file1,blob blob1) pb 读取文件到大字段变量
- .NET中的 Image.FromFile 方法会锁住文件的解决方法(转)
- 利用 hadoop 的 FileSystem copyFromLocalFile 方法实现文件上传HDFS中 Hadoop 版本 2.7.0
- ThinPHP第二十八天(F函数和file_put_contents区别|PHP生成PHP文件,Kindeditor编辑器使用方法)
- 关于文件保存到Oracle中BLOB字段的方法及例子
- 关于文件保存到Oracle中BLOB字段的方法及例子
- 对于image.fromfile方法在使用时,遇到的“正由另一进程使用,因此该进程无法访问此文件”解决方法
- 在项目中根据配置文件路径生成File对象的方法
- 如何直接下载保存在Oracl数据库中Blob字段的文件(不生成临时文件)???
- Image.FromFile 方法锁住文件解决方法
- Image.FromFile方法会锁住文件的解决方法(文件正由另一进程使用,因此该进程无法访问该文件)
- C# 加载图片image --(C#)Image.FromFile 方法会锁住文件的原因及可能的解决方法
- PB中自动生成的sql语句,在comment不存在时,自动使用name字段作为注释的设置方法
- Image.FromFile方法会锁住文件的解决方法(文件正由另一进程使用,因此该进程无法访问该文件)
- 利用 hadoop 的 FileSystem copyFromLocalFile 方法实现文件上传HDFS中 Hadoop 版本 2.7.0
- 从数据库中读取blob字段并生成图片文件
- C# 加载图片image --(C#)Image.FromFile 方法会锁住文件的原因及可能的解决方法
- C# 加载图片image --(C#)Image.FromFile 方法会锁住文件的原因及可能的解决方法
- 各种波形文件vcd,vpd,shm,fsdb生成的方法(zz)
- 如何用JAVA将二进制文件转换成BASE64格式保存到MySQL的Blob字段里并读出下载