Results 1 to 3 of 3

Thread: quickest i/o routine to process hundreds of ascii files

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    2

    Thumbs up

    I need to know the quickest way to read many (up to 3,000) smaller files (usually below 500 K) into memory. Right now I am reading them in one line at a time. I tried using input for the len of the file, but that did not help.

    Is there some way to make vb not do this sequentially - could I write something in C++ and call it from vb . . . anything please

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    There are many ways indeed to acomplish what you want to do. A COM object written in C++, would indeed be a very good way to do it. All you then need to do is to refernce the dll from your VB project and code away.

    Other than that, i would have said the Input function, and the Get function. I usually find that the Get function is quicker on smaller files, while the Input function is quicker on larger files.

    Code:
    Private Sub inputMethod(strFile As String)
        Dim strText As String
        
        Open strFile For Input As #1
        'get the whole file.
        strText = Input(LOF(1), #1)
        Close #1
        
    End Sub
    
    Private Sub getMethod(strFile As String)
        Dim bTemp As String
        Dim strText As String
        
        Open strFile For Binary As #1
        'redim the byte array to the size of the file
        ReDim bTemp(LOF(1) - 1) As Byte
        'get the file in binary
        Get #1, , bTemp
        Close #1
        'convert the byte array to a string
        strText = StrConv(bTemp, vbUnicode)
        
    End Sub
    Iain, thats with an i by the way!

  3. #3
    Guest
    Personally I would use the FileSystemObject. It allows you to open the file as a single string in one operation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width