PB读和写大于32K(32765B)数据

PB读和写大于32K(32765B)数据  


string export_filepath,export_filename
string gs_importfilepath,gs_importfilename

//读取大文本数据
if GetFileOpenName("选择要导入的文件", gs_importfilepath,gs_importfilename, "dat", &
+ "Dat Files (*.dat),*.dat," + "TEXT Files (*.txt),*.txt," +"All Files (*.*), *.*", gs_filepath, 18)()<>1 then return
long ll_FLength,ll_FileNum
string ls_filecontext,ls_tmp
int i,loops,j

debugbreak()
ll_FLength = filelength(gs_importfilepath)
ll_FileNum = FileOpen(gs_importfilepath,StreamMode!, Read!, LockWrite!, Replace!)
if ll_FLength > 32765 then
if mod(ll_FLength,32765) = 0 then
   loops= ll_FLength/32765
else
   loops= ll_FLength/32765 +1
end if
else
loops=1
end if
// read file
SetPointer(hourglass!)
for i=1 to loops
j=FileRead(ll_filenum,ls_tmp)
ls_filecontext=ls_filecontext + ls_tmp
next
FileClose(ll_FileNum)
mle_1.text=ls_filecontext


//写大文本数据
if Getfilesavename("选择保存路径",export_filepath,export_filename,&
"dat","DAT Files (*.dat),*.dat,"+ "TEXT Files (*.txt),*.txt,"+"ALL Files (*.*),*.*",gs_filepath,32770)<>1 then return
long ll_FLength,ll_FileNum
string ls_filecontext,ls_tmp
int i,loops,j
boolean lb_delete

debugbreak()
ls_filecontext=mle_1.text
ll_FLength = len(ls_filecontext)
ll_FileNum = FileOpen(export_filepath,StreamMode!, Write!, LockWrite!, Append!) //以追加的方式,打开选择的保存路径
if export_filepath=gs_importfilepath then //如果是以前的老文件,就把原来的文件删除.
FileClose(ll_FileNum)
lb_delete=filedelete(gs_importfilepath)
ll_FileNum = FileOpen(export_filepath,StreamMode!, Write!, LockWrite!, Append!)
end if

if ll_FLength > 32765 then
if mod(ll_FLength,32765) = 0 then
   loops= ll_FLength/32765
else
   loops= ll_FLength/32765 +1
end if
else
loops=1
end if
// write file //每次向文件中写32765个字节,分多次写
for i=1 to loops
ls_tmp=left(ls_filecontext,32765)
FileWrite(ll_FileNum,ls_tmp)
ls_filecontext=right(ls_filecontext,len(ls_filecontext) - 32765)
next
FileClose(ll_FileNum)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值