Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple users reading contents of .txt file

Status
Not open for further replies.

markhkram

IS-IT--Management
Dec 30, 2008
32
US
I have probably close to 1,000 users that I want to randomly access the same file every 5 minutes located on a server. For sure at some times there will be multiple connections to the same file. I have the following code, and was wondering if it would cause some file/lock or access issues:
Code:
        Dim strLine As String
        Dim objStreamReader
        Dim i As Integer

        'Pass the file path and the file name to the StreamReader constructor.
        objStreamReader = New StreamReader("C:\test.txt")

        'Read the first line of text.
        strLine = objStreamReader.ReadLine

        'Continue to read until you reach the end of the file.
        Do While Not strLine Is Nothing
            i = i + 1
            'Write the line to the Console window.
            If i = 3 Then ListBox1.Items.Add(strLine) 'Write Line 3
            If i = 5 Then ListBox1.Items.Add(strLine) 'Write Line 5

            'Read the next line.
            strLine = objStreamReader.ReadLine
        Loop

        'Close the file.
        objStreamReader.Close()

Would it be better to have this file copied to the local machine and then read locally? Or by using this method can multiple users read this file? I wont ever be writing to it.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top