二进制文件写入后 出现双文件尾
我对一个二进制文件按字节读取后,修改部分字节,再写入另一个文件,然后我又在UltraEdit下手动改了一个文件,手工修改的文件和程序修改的文件用UltraEdit文件比较完全等同,但放到处理机上(小红帽)读取时提示 double EOF
源代码如下 :
Public fs, fw As FileStream
....
fs = File.OpenRead(TextBox1.Text)
temp = Mid(TextBox1.Text, 1, InStrRev(TextBox1.Text, ".") - 1) + "_fixed.s"
fw = File.OpenWrite(temp)
fs.Read(wb1, 0, 2) : fw.Write(ffid_1, 0, 2)
fs.Read(wb2, 0, 30) : fw.Write(wb2, 0, 30)
fs.Read(wb6, 0, 3) : fw.Write(ffid_2, 0, 3)
fs.Read(wb5, 0, 29) : fw.Write(wb5, 0, 29)
fs.Read(wb6, 0, 3) : fw.Write(ffid_2, 0, 3)
fs.Read(wb5, 0, 29) : fw.Write(wb5, 0, 29)
For i = 0 To 15 Step 1
fs.Read(wb3, 0, 32) : fw.Write(wb3, 0, 32)
Next
fs.Read(wb4, 0, 2048) : fw.Write(wb4, 0, 2048)
aux_num = Val(shot_FFID(3))
data_num = Val(shot_FFID(4))
sample_points = Val(shot_FFID(5))
ReDim trace_data(sample_points * 4 - 1)
For i = 0 To aux_num + data_num - 1
fs.Read(wb1, 0, 2) : fw.Write(ffid_1, 0, 2)
fs.Read(wb7, 0, 15) : fw.Write(wb7, 0, 15)
fs.Read(wb6, 0, 3) : fw.Write(ffid_2, 0, 3)
fs.Read(wb0, 0, 224) : fw.Write(wb0, 0, 224)
fs.Read(trace_data, 0, sample_points * 4)
fw.Write(trace_data, 0, sample_points * 4)
Next
fs.Dispose()
fw.Dispose()