如何把两个文件合并。如A.txt和B.txt,我想合并成A.txt或C.txt

formine 2003-10-20 04:45:23
如何把两个文件合并。如A.txt和B.txt,我想合并成A.txt或C.txt,在Dos下可以Copy A.txt+B.txt C.txt,但在VB程序里如何实现?
...全文
579 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
kmzs 2003-10-22
  • 打赏
  • 举报
回复
解贴把,只能用在Win98以上的Windows中
chenziteng 2003-10-22
  • 打赏
  • 举报
回复
回rainstormmaster(rainstormmaster):
原来你是指不同的Windows系统啊,误会了.

回楼上的金兵甲:
WinCE也算是Windows吧,再说我问的是VB不是EVB

回楼上的金兵乙:
我问的是VB不是VBS

阿建像熊猫 2003-10-22
  • 打赏
  • 举报
回复
FSO方法。
先读取A.txt文件内容。在写到B.txt文件,再创建新文件C.txt文件。
读取文件:
dim fso as new filesystemobject ,fil1 as file,ts as textstream

set ts=fil1.openastextstream(forreading)
s=ts.readline
msgbox s
ts.close

写入文件:
dim fso,txtfile
set fso=createobject("scripting.filesystemobject")
set txtfile=fso.createtextfile("c:\testfile.txt",true)
txtfile.write("文字")
txfile.close

复制文件:
dim fso as new filesystemobject,txtfile,fil1,fil2
set txtfile=fso.createtextfile("c:\tetfile.txt",true)
开始复制fil1.copy("要复制的文件目录")
hxy2003 2003-10-21
  • 打赏
  • 举报
回复
up
mmcgzs 2003-10-21
  • 打赏
  • 举报
回复
dim a() as byte

redim a(filelen("a.txt")-1)

dim b() as byte

redim b(filelen("b.txt")-1)

open "a.txt" for binary as #11

open "b.txt" for binary as #22

open "c.txt" for binary as #33

get #11,,a

put #33,,a

get #22,,b

put #33,,b

close(11)

close(22)

close(33)

kmzs 2003-10-21
  • 打赏
  • 举报
回复
VBS可以用在随便什么系统上,。。。
kmzs 2003-10-21
  • 打赏
  • 举报
回复
EVB 可以用在Windows CE上
demo001 2003-10-21
  • 打赏
  • 举报
回复
最好是加个参数copy/b,用二进制连接
rainstormmaster 2003-10-20
  • 打赏
  • 举报
回复
//诚心请教楼上的:VB除了在Windows上还能在哪个系统上用?
只能在windows上用
我的意思是说,如果在98下,应该:
Shell "Command.com /c copy d:\a.txt+d:\b.txt d:\c.txt"
chenziteng 2003-10-20
  • 打赏
  • 举报
回复
诚心请教楼上的:VB除了在Windows上还能在哪个系统上用?
rainstormmaster 2003-10-20
  • 打赏
  • 举报
回复
不过上面的方法受到操作系统的制约,没有通用性

rainstormmaster 2003-10-20
  • 打赏
  • 举报
回复
Shell "cmd /c copy c:\a.txt+c:\b.txt c:\c.txt"

同意 lxcc(虫莲)
kmzs 2003-10-20
  • 打赏
  • 举报
回复
用2进值读写合并即快又好且通用,就是注意文件要能够读写
demo001 2003-10-20
  • 打赏
  • 举报
回复
我觉得lxcc(虫莲)如果copy/b就更好了

这样就不仅可以连接文本文件

还可以连接非文本的任何文件
lxqlogo0 2003-10-20
  • 打赏
  • 举报
回复
同 lxcc(虫莲)
射天狼 2003-10-20
  • 打赏
  • 举报
回复
虫莲的意思亦我所欲也~~
mmcgzs 2003-10-20
  • 打赏
  • 举报
回复
dim a() as byte

redim a(filelen("a.txt")-1)

dim b() as byte

redim b(filelen("b.txt")-1)

open "a.txt" for binary as #11

open "b.txt" for binary as #22

open "c.txt" for binary as #33

get #11,a

put #33,a

get #22,b

put #33,b

close(11)

close(22)

close(33)
golden24kcn 2003-10-20
  • 打赏
  • 举报
回复
dim FileNum as long
dim tmp

a="a.txt"
filenum=freefile()
open a For Binary As FileNum
tmp=input( filelen(a),filenum)
close filenum
filenum=freefile()
c="c.txt"
open C For Binary As filenum
write filenum , tmp
close filenum

b="b.txt"
filenum=freefile()
open a For Binary As FileNum
tmp=input( filelen(a),filenum)
close filenum
filenum=freefile()
c="c.txt"
open C For Binary As filenum
write filenum , tmp
close filenum
jiuzhangcs21dn 2003-10-20
  • 打赏
  • 举报
回复
FSO模型用文件读写函数,先把B.txt内容读入内存,在用写函数(好象是write)追加到A.txt.
lxcc 2003-10-20
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Shell "cmd /c copy c:\a.txt+c:\b.txt c:\c.txt"
End Sub
1.linux系统介绍 以windows为内核的操作系统有哪些:win10   win8   win7  xp  系统    windows server 以linux为内核的操作系统有哪些:centos  ubuntu  debian   windows和linux  linux:服务器   安全    稳定 高效    windows:办公  家用  2.安装linux注意事项 对centos系统 的基本使用   有哪些文件夹   对文件/文件夹 进行操作  创建 删除  修改 移动 复制   写入 home 存放所有用户文件的根目录  soft :安装软件 cd  ll mkdir 创建文件  touch 空文件  echo sdsd>a.txt       vi a.txt vi c.txt  打开文件  按下i键  改为写入的模式    写完之后保存: 先按下esc 按键再按下:w 保存 :q退出  :wq    写完之后不保存 强制退出  esc  :q! 删除文件/文件夹 rm -rf a.txt  b.txt rm -rf soft 复制 如果复制文件 cp  要复制的文件名   复制出来的文件名子    cp  a.txt   a1.txt 如果复制的是文件夹的 cp -r soft/   soft1 展示一个文件中的内容 cat  移动文件  mv  temp1   temp2 重命名 mv  temp1   temp2 查找: find /(查找的路径)  -name   *.txt    b 清屏  clear tab 按键 可以帮助我们把输入的内容补全   3.配置局域网  需要通过ssh软件远程操作linux系统 远程操作centos系统  在windows操作系统中通过一款软件来远程操作虚拟电脑中的centos系统  ssh软件: xshell  secureCRT 第一步在win10系统中下载并且安装ssh软件 secureCRT    第二步:只要知道centos系统所在电脑的公网IP  登录账户和密码      /  win10和centos系统所在的两台电脑在同一个局域网内  局域网IP  登录账户和密码 第三步:centos系统 进行局域网的设置 往网卡中写入一些数据   win10写入的方式:桌面的化操作和centos系统写入的方式是不一样的  ip 网关 子网掩码 NM_conteolle。。。 命令  找到往网卡写入数据的文件    重新启动网络服务 开启22端口   重启防火墙服务 网络桥接网络  *************************端口是否开启  4.配置外网  下载软件1.下载并且安装到系统中 node.js环境   npm install bootstrap   默认的镜像库 centos系统    yum install  服务名     默认的镜像库  2.自己下载服务  wget 服务的网络地址 自己单独安装  比较灵活 安装难度大 windows系统  exe文件 linux       rpm包

7,763

社区成员

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

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