I am using this loop several times in my app
Dim X As Short
For X = 1 To 5
Dim FSO As File
Dim FStreamObject As FileStream
FSO.Create(Application.StartupPath & "\" & X & ".txt")
FSO.SetAttributes(Application.StartupPath & "\" & X & ".txt", FileAttributes.Archive)
Next

It works fine the first time I go throught the loop. The problem is when it goes through the loop a second time, it generates the error "The process cannot access the file "C:\1.txt" because it is being used by another process.

Is there a way to release the handle on the file?

Also, I found how to write a byte array to a text file, but how do I write a string type?



Thanks