一個過程..... Private Sub WriteFile(ByVal infile As String, outfile As String) Dim FnumIn As Long, FnumOut As Long, myByte As Byte FnumIn = FreeFile() Open infile For Binary As #FnumIn FnumOut = FreeFile() Open outfile For Binary As #FnumOut While Not EOF(FnumIn) Get #FnumIn, , myByte Put #FnumOut, , myByte Wend Close (FnumOut) Close (FnumIn) End Sub
请chinayang给出代码的注解,谢谢
不会不知道open语句吧? open 文件名 for 打开模式 as #文件号 1.Binary 为二进制方式打开文件! 文件号是识标符 2。用Get#文件号,位置,变量(常为一个数组)读文件并保存在指定的变量中 3。用Put#文件号,位置,变量(常为数组)将变量以二进制方式写文件 如: private sub command1_click() dim aa()as byte '定义aa为字节数组 open "C:\a.exe" for binary as #1 redim aa(lof(1)-1) ‘将aa的大小定义为和文件的大小一样 Get#1,,aa ’读出文件 close#1 open "D:\b.exe"for binary as #2 Put#1,,aa ‘写入文件 close#2
Private Sub WriteFile(ByVal infile As String, outfile As String)
Dim FnumIn As Long, FnumOut As Long, myByte As Byte
FnumIn = FreeFile()
Open infile For Binary As #FnumIn
FnumOut = FreeFile()
Open outfile For Binary As #FnumOut
While Not EOF(FnumIn)
Get #FnumIn, , myByte
Put #FnumOut, , myByte
Wend
Close (FnumOut)
Close (FnumIn)
End Sub
open 文件名 for 打开模式 as #文件号
1.Binary 为二进制方式打开文件!
文件号是识标符
2。用Get#文件号,位置,变量(常为一个数组)读文件并保存在指定的变量中
3。用Put#文件号,位置,变量(常为数组)将变量以二进制方式写文件
如:
private sub command1_click()
dim aa()as byte '定义aa为字节数组
open "C:\a.exe" for binary as #1
redim aa(lof(1)-1) ‘将aa的大小定义为和文件的大小一样
Get#1,,aa ’读出文件
close#1
open "D:\b.exe"for binary as #2
Put#1,,aa ‘写入文件
close#2