NewsBot
1
Language: VB.Net
Framework: 2.0
IDE: Visual Studio 2005
*
Hi,
More...
View All Our Microsft Related Feeds
Framework: 2.0
IDE: Visual Studio 2005
*
Hi,
I have an application which makes use of File IO*and*I keep running into a*problem where a txt file is still be used by some process even after I close readers/writers.
Is there a way to make sure all processes on a file are stoped or do some kind of check to see if the file is not being used by something else.
I'll explain a little bit of*what I am doing incase it helps solves my problem.
I*have a .txt file*which my application writes label information too. Each line in the txt file is a new label. After application writes to the .txt*file it closes the writer.
I also have a function which uses a reader loop to*count the lines in the txt file to see how many labels*the application has*written. After the loop is finished the reader closes.
Once the user clicks*a "make label" button if the count of labels is not zero*my application automates MS word, opens a pre-saved doc file*with a table in it, then reads each line from the txt file into a different tabel cell. After the loop for writing info into the cells is finished the reader for the txt file is closed, deleted, and a new .txt file is created. The MS word doc is then*saved and made visible to the user.
I sometimes get a file io error if the user clicks the "make label" button again within 60 seconds of this process finishing. (after the .doc file is shown)
Basicly the error says the .txt file is still in use.
I believe the problem occurs because the file io has not finished recreating the .txt file after it's deleted, but I don't understand why it takes so long or what I can do to make sure the txt file is created (and not in use) before my application tries to use it again.
Is there a way to make sure all processes on a file are stoped or do some kind of check to see if the file is not being used by something else.
Thanks for any help
More...
View All Our Microsft Related Feeds