hey,I know the foll. Method to read the textfile line by line. & it is also working Fine. But I want to know that method which includes EOF(End Of File).
Can Somebody tell me that method.

sFilename = "C:\Listview.txt"
        If Dir(sFilename.ToString) <> "" Then
            sFileReader = System.IO.File.OpenText(sFilename)
            sInputLine = sFileReader.ReadLine()
            Do Until sInputLine Is Nothing
                         sInputLine = sFileReader.ReadLine()
            Loop
        End If

How are saving sImputLine? As I see you are overwritting it with each read.
I use:

Dim ary As String()

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If My.Computer.FileSystem.FileExists("c:\test.txt") Then
            Dim str As String = My.Computer.FileSystem.ReadAllText("c:\test.txt")
            str.Split(ary, vbNewLine)
        End If
    End Sub

Now all your data is in an array.

Imports System.IO
Module Module1

   Sub Main(ByVal args As String())
      Dim fileIn As New StreamReader(args(0))
      Dim strData As String = ""
      Dim lngCount As Long = 1

      While (Not (fileIn.EndOfStream))
         strData = fileIn.ReadLine()
         Console.WriteLine(lngCount & ": " & strData)
         lngCount = lngCount + 1
      End While
   End Sub

End Module
Private Sub readTextFile(ByVal fileName As String)
        Try
            If Not System.IO.File.Exists(fileName) Then Exit Sub
            Dim strContent As String()
            strContent = System.IO.File.ReadAllLines(fileName)
            Dim x As String = ""
        Catch ex As Exception
             messagebo.show(ex.tostring)
        End Try

    End Sub

hy
i m making antivirus using MD5 hash ...so in that i stucked that how to clean a deteced virus ????acn any one tell me exact code for cleaning a virus file and also for qurantine.its in vb.net.plz help me
Regards
awais
awais310@gmail.com do contact me on mail too

Hí Guys!

PLease Help Me on the following problem.

How can i do the next thing?

I want to know what's the data in a textfile's line. If i'v got the line number.

For example:

variable line_number = 5
In the c:\test.txt on the 5th line the data is "Washington"

So the answer is Washington

Thank u for your help!

Karpati, please start a new thread for your question so this one can be closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.