|
-
Mar 15th, 2007, 09:09 AM
#1
Thread Starter
Addicted Member
Watching a text file being written to, then when finished loading it into a text fil
Hi Everyone,
Is there a way VB.NET 2005 can watch a text file be written to, then once the writing stops VB can know to pull the text file into a listbox? Any help would be much appreciated.
-
Mar 15th, 2007, 10:33 AM
#2
Re: Watching a text file being written to, then when finished loading it into a text fil
What program is used to edit the text file?
-
Mar 15th, 2007, 10:53 AM
#3
Thread Starter
Addicted Member
Re: Watching a text file being written to, then when finished loading it into a text
I am calling a command line programmatically inside of my vb.net program (see below)
Code:
Shell(Environ$("comspec") & " /k net view > " & Chr(34) & "C:\netview.txt" & Chr(34), AppWinStyle.Hide)
Then I am having my app sleep while the file builds (see below)
Code:
Dim x As Long = 1200 'in milliseconds
System.Threading.Thread.Sleep(x) 'wait for 1200 milliseconds
Then the app pulls the text file into a listbox after the sleep is complete.
The problem is that sometimes I don’t specify a long enough time to sleep and VB doesn’t pull all the data because the file was still being written to.
I am trying to find a way for VB to check and see when the file is done being written to, so I will have a more ironclad way of pulling all the data from the text file and not just a partial piece of it.
-
Mar 15th, 2007, 10:57 AM
#4
Re: Watching a text file being written to, then when finished loading it into a text fil
Use a timer to check the file at intervals rather than trying to force your thread to sleep for a certain period of time.
-
Mar 15th, 2007, 11:23 AM
#5
Thread Starter
Addicted Member
Re: Watching a text file being written to, then when finished loading it into a text
How can I check to see if the file is done?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|