Jump to content
Xtreme .Net Talk

Recommended Posts

Guest boskomihic
Posted
What have I to set up so I can start using StreamReader or StreamWriter?
Guest bananafish
Posted (edited)

Here is one example of using Stream Reader

 

  Private Function ReadIniFile() As ArrayList
     '****************************************
     '* Read the Ini File into an Array List *
     '****************************************
     Dim srIniFile As System.IO.StreamReader
     Dim strFilePath As String
     Dim alFile As ArrayList = New ArrayList()
     Dim strRec As String
     Try
        mintTotal = 0
        strFilePath = Path.ChangeExtension([Assembly].GetExecutingAssembly.Location, "ini")
        srIniFile = System.IO.File.OpenText(strFilePath)

        '*******************************
        '* Read the File               *
        '*******************************
        Do
           strRec = srIniFile.ReadLine()
           If strRec <> Nothing Then
              alFile.Add(strRec)
              mintTotal += 1
           End If
        Loop Until strRec = Nothing
        Return alFile

     Catch ex As Exception
        moErr.LogError(ex)
     Finally
        If Not srIniFile Is Nothing Then
           srIniFile.Close()
        End If
     End Try

  End Function

Edited by Derek Stone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...