How Can I Append a file in use

I need to a text to a file that is open.

Dim fs As New FileStream(DestEFB, FileMode.Append, FileAccess.Write, FileShare.Write)
                fs.Close()
                Dim sw As New StreamWriter("Destattion_Open_File.txt", True)
                Dim NextLine As String = vbCrLf & "This is the appended text."
                sw.Write(NextLine)
                sw.Close()

But I get the file in use error
Anyone now a way around this.
buzzcarterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
It is not a programming problem. The operating system will not allow this to prevent loss of data. If user one makes a change and then your program makes a change, the first save will be overwritten by the second.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Right...you need to pause for a second or two after "fs.Close()" and allow the operating system to finish with the file and release the file handles completely before attempting to append to it...
0
buzzcarterAuthor Commented:
Thanks Idle Mind but the exception fire @ Dim fs As New FileStream(DestEFB, FileMode.Append, FileAccess.Write, FileShare.Write)

I am look for away around this filesystem protection.
0
buzzcarterAuthor Commented:
This is not possible. One possible solution is to be the first application to create the file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.