Results 1 to 5 of 5

Thread: Opening file problem...

  1. #1

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    All I want to do is to open a file for reading using the FileSystemObject yet somehow I seem to be missing something somewhere! I keep getting the error 'Input past end of line' in the following code:
    Code:
    Public Sub Increase(vFileName As String)
    
       Dim FSO           As New FileSystemObject
       Dim ProjectPath   As String
       Dim vFile         As File
       Dim Exists        As Boolean
       Dim TXT           As TextStream
       Dim strTemp       As String
    
       ProjectPath = FSO.BuildPath(App.Path, vFileName)
       
       Exists = FSO.FileExists(ProjectPath)
    
       If Exists Then
          Set vFile = FSO.GetFile(ProjectPath)
       
          Set TXT = vFile.OpenAsTextStream(ForReading)
       
          strTemp = TXT.ReadAll '<<--Error occurs here
          
          TXT.Close
    
       End If
    
    End Sub

    Any help would be appreciated

    cheers

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754

    Question

    Hi Shaun,

    I just read in MSDN that the ReadAll method can be memory hungry, I am currently (as we speak ) running it on an 8mb text file, it worked fine on 1/2 a meg, so I thought i'd try and kill it . What sort of file are you opening? and how big is it?
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    Thanks for the reply Crispin. I can appreciate that but the file that I am trying to open contains a whole '6 LINES'.

    All I am trying to do is open it to read (i will work out the writing bit later!! ).

    And before anybody says to use GET and PUT etc.. I want to get it to work with the FSO.

    What am I doing wrong???????

    Cheers

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    mail me the file
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243

    Red face Oooops

    Hi Crispin,
    Thanks for your help. I was just about to mail it to you when I realised that the text file actually contained no text!!!
    It must have got deleted when I was messing about with the 'ForReading','ForWriting' parameter!

    Must be time to go home!!!!!!!!!!!!!!!

    Cheers

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

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