Results 1 to 3 of 3

Thread: [RESOLVED] Wait for a text file to stop being written to, then open the text file?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Resolved [RESOLVED] Wait for a text file to stop being written to, then open the text file?

    Hi All,

    Is there a way vb.net 2005 can check to see when a file is done begin written to, then open that file and pull it's contents into a listbox?

    I have a command line outputting data to a text file, then having my vb.net app pull the file from the text file to a listbox. Currently I have it working off of a delay, but this can be problematic due to underestimating the write time, then the .net app can not pull the data at all.

    If there is a way for vb.net to wait, check, wait, check, if done, pull the data to a listbox? This would certainly be much better than a manual delay.

    Any help would be much appreciated. Thanks!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Wait for a text file to stop being written to, then open the text file?

    Start a Timer and try to open the file in the Tick event handler. If it succeeds then stop the Timer and read the data, otherwise let the Timer keep on Ticking.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Re: Wait for a text file to stop being written to, then open the text file?

    Thanks jmcilhinney,

    That worked perfectly!

Posting Permissions

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



Click Here to Expand Forum to Full Width