调用一个过程,在过程中用一个数组读入文件内容。当读过几个文件后,再读一个几M的大文件,出现内存溢出错误。先读大文件则正常执行。似乎是数组没有释放,为什么?怎么办? Dim Filenr As Integer
Dim ByteArray() As Byte
'Open the source file and read the content
'into a bytearray
Filenr = FreeFile
Open SourceFile For Binary As #Filenr
ReDim ByteArray(0 To LOF(Filenr) - 1)
Get #Filenr, , ByteArray()
Close #Filenr
Dim ByteArray() As Byte
'Open the source file and read the content
'into a bytearray
Filenr = FreeFile
Open SourceFile For Binary As #Filenr
ReDim ByteArray(0 To LOF(Filenr) - 1)
Get #Filenr, , ByteArray()
Close #Filenr
erase bytearray
试了,依然如故。还有其他办法吗?
Dim ByteArray() As Byte
'Open the source file and read the content
'into a bytearray
Filenr = FreeFile()
Open SourceFile For Binary As #Filenr
ByteArray = InputB(LOF(1), #1)
Close #Filenr
Erase ByteArray我读了一个三兆多的文件,读了十几次,也没问题啊~~
出错时,停留在ReDim ByteArray(0 To LOF(Filenr) - 1)语句。
压缩加密量之后问题解决。
谢谢各位。