当前位置: 代码迷 >> PB >> pb filewrite 函数怎么写出大于32k的文本文件
  详细解决方案

pb filewrite 函数怎么写出大于32k的文本文件

热度:57   发布时间:2016-04-29 09:50:46.0
pb filewrite 函数如何写出大于32k的文本文件
每次只能写32k,如何循环写出大于32k的文本数据呢?

------解决方案--------------------
li_fileno = FileOpen( "m:\ "+u_name,streamMode!, Write!, Shared!,replace!) 

If ll_length > 32765 Then 

If Mod(ll_length,32765) = 0 Then 
li_loops = ll_length/32765 
Else 
li_loops = ll_length/32765 + 1 
End If 
Else 
li_loops = 1 
End If 
temp=emp_file 
For li_i = 1 To li_loops 
fileWrite(li_fileno,temp) 
temp=blobmid(emp_file,li_i*32765,32765) 
Next 

FileClose(li_fileno)
------解决方案--------------------
VB code
      //将选定的文件变成blob变量                //as_path 选定文件的路径        //abb_file 返回的blob变量                boolean lb_return        blob lbb_file,lbb_get        string ls_path        long li_handl,li_length        long i,li_loop                ls_path = as_path//文件的路径                lb_return = FileExists (ls_path)//判断文件是否存在        if lb_return = false then             messagebox('','该文件不存在,请重新选择!')            return false        end if                li_length = filelength(ls_path)//文件的长度(字节)        li_handl = fileopen(ls_path,streammode!,read!,lockreadwrite!,append!)//打开文件        if li_handl = -1 then//cc             messagebox('',ls_path+'文件不能打开,请检查!')           return false       else           //在文件可以打开的情况下,将文件变成blob变量                                   if li_length >32765 then//dd                           if mod(li_length,32765) = 0 then                    li_loop = li_length/32765                else                    li_loop = ( li_length/32765 ) + 1                end if                                for i=1 to li_loop                                        fileread( li_handl, lbb_get)                    lbb_file = lbb_file + lbb_get                next                            else                                fileread( li_handl, lbb_file)            end if//dd                    end if//cc                   fileclose( li_handl )//关闭文件                    abb_file = lbb_file