Does an IO exception get thrown if the disk is full?

Jac*_*ada 3 .net c#

What exception is thrown in the .NET Framework when trying to write a file but the disk is full?

Does Windows buffer file writes?

Kei*_*ith 6

您将获得IO异常:

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

System.IO库处理读取和写入磁盘的实际任务,并将它们包装在托管代码中,因此您不应使用它们获取任何非托管异常.

它也值得尝试(使用其中一个粗制的小型USB棒,它们随处可见)来查看代码会发生什么 - 这通常是找到这种东西的最佳方式.

  • 磁盘满了? (2认同)