Open oldFile For Binary As #1
Open newfile For Binary As #2
Do While Not EOF(1)
Get #1, , theByte
theByte = Val(Text) Xor theByte
Put #2, , theByte
Loop
Close #1
Close #2
之前是这样做的,找到一个方法把文件一次读入内存,不知道怎样让他做xor运算。
Dim Buff As String
nfile = Dir1.Path & "\" & File1.FileName
Open nfile For Binary As #3
    Buff = Space(LOF(3))
    Get #3, , Buff
Close #3

解决方案 »

  1.   

    Open oldFile For Binary As #1
    Open newfile For Binary As #2
    Do While Not EOF(1)
    Get #1, , theByte
    theByte = theByte Xor Val(Text)
    Put #2, , theByte
    Loop
    Close #1
    Close #2
      

  2.   

    Dim fn As Integer, b() As Byte
    Dim i As Long, n As Long
    fn = FreeFile
    Open fName For Binary As #fn
    n = LOF(fn) - 1
    ReDim b(n)
    Get #fn, , b
    Close #fn
    For i = 0 To n
         b(i) = b(i) Xor theByte
    Next i
    fn = FreeFile
    Open fName For Binary As #fn
    put #fn,,b
    close #fnOpen newFileName as 
        
      

  3.   

    Dim fn As Integer, b() As Byte
    Dim i As Long, n As Long
    fn = FreeFile
    Open fName For Binary As #fn
    n = LOF(fn) - 1
    ReDim b(n)
    Get #fn, , b
    Close #fn
    For i = 0 To n
         b(i) = b(i) Xor theByte
    Next i
    fn = FreeFile
    Open newfName For Binary As #fn
    put #fn,,b
    close #fn