关于pb对文件的读写

tempest 2003-09-21 08:18:59
问题:用pb把一个文件读入,然后经过处理(比如去掉空格)在写成令一个文件。
用流的方式进行读写!如果文件大于32765字节读取我知道怎么读入,在写的时候我发现只能写入32765字节,其余的都被截取了!!
谁知道怎样写超过32765字节的部分谢谢!
...全文
155 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chrisfy 2003-09-22
  • 打赏
  • 举报
回复
循环分批写入
jdsnhan 2003-09-22
  • 打赏
  • 举报
回复
同意大家的,如果大于32767,也要循环写。
mah1212 2003-09-22
  • 打赏
  • 举报
回复
blob
rogery 2003-09-21
  • 打赏
  • 举报
回复
你保存的进修的表的字段是什么类型的?

liliang800207 2003-09-21
  • 打赏
  • 举报
回复
记录下每次读完32765字节的地方
下次再从此读
这样就可以了
就是分批读取
csdnjly 2003-09-21
  • 打赏
  • 举报
回复
to iagcel(孤星) :
你这不是在抄袭我的代码吗?
未经许可,不许转载
iagcel 2003-09-21
  • 打赏
  • 举报
回复
循环读写啊,给你一个例子:
long flen, bytes_read, new_pos
integer fh, ret,loops,i
blob b, tot_b
string txtname, named
string defext = "BMP"
string Filter = "bitmap Files (*.bmp), *.bmp"
ret = GetFileOpenName("Open Bitmap", txtname, &
named, defext, filter)
// Set a wait cursor
SetPointer(HourGlass!)
// Get the file length, and open the file
flen = FileLength(txtname)

// Determine how many times to call FileRead
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF

IF ret = 1 THEN
fh = FileOpen(txtname, StreamMode!, Read!, LockRead!)
IF fh <> -1 THEN
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(fh, b)
tot_b = tot_b + b
NEXT
FileClose(fh)
p_1.SetPicture(tot_b)
p_1.setredraw(true)
cb_1.visible=true
pic=tot_b
END IF
END IF
klbt 2003-09-21
  • 打赏
  • 举报
回复
写的时候,也一样,超过32765字节分次写入。

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧