PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
need help opening a text file in use by another program-VBForums
Results 1 to 6 of 6

Thread: need help opening a text file in use by another program

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    3

    need help opening a text file in use by another program

    I need to be able to view another programs chatlog while it is running. this is the existing code. right now for testing it just reads the first line of file. this reads the file just fine as long as the other program isnt running but if it is running i get an error stating that the file is in use by another process. I'm using vb 2010 express.
    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim fileReader As System.IO.StreamReader
    3.         fileReader = _
    4.         My.Computer.FileSystem.OpenTextFileReader("C:\chatlog")
    5.         Dim stringReader As String
    6.         stringReader = fileReader.ReadLine()
    7.         textbox1.text = stringReader
    Last edited by Hack; May 22nd, 2012 at 12:56 PM. Reason: Added Highlight Tags

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: need help opening a text file in use by another program

    Why are you trying to read someone else's chat file?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    3

    Re: need help opening a text file in use by another program

    im workin on a 3rd party addon for a game. it does not break any rules or anything like that. it needs to see the chatlogs to get info.

  4. #4
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: need help opening a text file in use by another program

    Very well...then I will move your thread to the appropriate VBForums section, which is VB.NET
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  5. #5
    New Member
    Join Date
    Apr 2012
    Location
    Florida, USA
    Posts
    5

    Re: need help opening a text file in use by another program

    This opens the filestream as read only and passes the filestream to a streamreader.

    Code:
    Dim chatFileStream As New FileStream("c:\Chat.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
    Dim chatFileReader As New StreamReader(chatFileStream)

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    3

    Re: need help opening a text file in use by another program

    that did it, thank you for the response. it has been stumping me for two days

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width