Thanks, Cor.
I found something weird:
Class FullDiskTest
Public Shared Sub Main()
Dim arch As System.IO.FileStream
Dim a(511) As Byte
arch = New System.IO.FileStream("a:\che.bin", System.IO.FileMode.OpenOrCreate)
Try
arch.Seek(1300000, System.IO.SeekOrigin.Begin) 'Useful from the second time it runs...
Do
arch.Write(a, 0, 512)
Loop
Catch exc As System.Exception
System.Console.WriteLine(exc.ToString)
End Try
'Everything fine until now.
Try
arch.Close() 'Generates a Disk Full exception... and the file is not closed!
Catch exc As System.IO.IOException
System.Console.WriteLine(exc.ToString)
End Try
System.Console.ReadLine()
End Sub
'The program exits with an unhandled exception!
End Class
I have changed the arch.Close() line with theese others:
arch=nothing
System.GC.Collect() '(Generates an exception only inside the IDE)
System.GC.WaitForPendingFinalizers()
Theese last lines generate an unhandled exception (although they are inside the Try block).
The file is not unlocked until the program exits.
It seems to me that a Full Disk Exception is generated when the GC tries to close the file, but the GC doesn't handle the error, neither propagate it to the program.
Well, can anybody test it and tell me if it is the expected behavior?
Regards.
"Cor" <
[email protected]> escribió en el mensaje | Hi Jose,
|
| that is clever
|
| >You can test it using a diskette: Fill it with some files and then test the
| methods.
| >Under XP you can assign a user a very small disk quota and fill it for
| testing.
|
| Cor
|
|