Re: StreamWriter Problem



On Dec 9, 1:10 am, "Teemu" <tsir...@xxxxxxxxxxx> wrote:
"kimiraikkonen" <kimiraikkone...@xxxxxxxxx> kirjoitti viestissänews:43b2cff0-40c7-405f-a663-2dbbe83436a7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

No, using with debugger or seperate executable makes no difference.

The last thing I can imagine is that antivirus software checks that file
sometimes and that causes this strange behavior. Or is your loading function
working properly? Does it close all streams?

I tried to loop your code 1000 times twice and no exceptions occurred.

-Teemu

Antivirus is disabled when trying this. However, this happens very
rarely, even sometimes i have to do this for hundres of times to
reproduce the problem, and only happens with overwritten files(very
rare) with that streamwriter code:

If Save.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
Try
myStreamWriter =
System.IO.File.CreateText(Save.FileName)
myStreamWriter.Write(TextBox1.Text)
myStreamWriter.Flush()
myStreamWriter.Close()
myStreamWriter.Dispose()
Catch ex As Exception
msgbox(ex.message)
End If

Finally
If Not myStreamWriter Is Nothing Then
myStreamWriter.Close()

End If

End Try

Anyway. I'd better test the codes for a while which author's
recommended. Thanks all.
.