Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: Intermediate
May 4, 2002

LoadTextFile - Load the contents of a text file

' Returns the content of the specified text file

' Note: it can throw an exception
' Usage: Dim FileContent As String = LoadTextFile("C:\Autoexec.bat")

Function LoadTextFile(ByVal FilePath As String) As String
    Dim sr As System.IO.StreamReader

    Try
        sr = New System.IO.StreamReader(FilePath)
        LoadTextFile = sr.ReadToEnd()
    Finally
        If Not sr Is Nothing Then sr.Close()
    End Try
End Function
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap