tags:

views:

234

answers:

2

As above but doesnt windows buffer the file system?? Does this mean that when you write this could work but later when flushed it throws an exception....

Have I got this right

+1  A: 

You could check the Win 32 Exception after what you have fails to see if that gives more detail:

     Win32Exception ex = new Win32Exception();
     string low_level_error = ex.Message;

How are you writing to disk? For FileStream it says:

"Be sure to call the Dispose method on all FileStream objects, especially in environments with limited disk space. Performing IO operations can raise an exception if there is no disk space available and the Dispose method is not called before the FileStream is finalized."

SwDevMan81
+6  A: 

You will get an IO exception:

System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

The System.IO library handles the actual tasks of reading and writing to disk and wraps them in managed code, so you shouldn't get any unmanaged exceptions using them.

It's also worth trying this (with one of those shoddy small USB sticks they give out everywhere) to see what happens with your code - that's usually the best way of finding out this sort of thing.

Keith
I d also like to know the answer to exactly WHEN the exception will get thrown
ChloeRadshaw
When the disk is full?
tster
The exception will be thrown when you attempt a write operation (or to open a file for writing, I think) on a full disk. Read operations on a full disk won't throw the exception.
Keith