"IOException: There is not enough space on the disk." while there is enough space
05:59 05 Mar 2012

I made sequence of operations (on local disk):

  1. Copy file to ###.bak
  2. Save file to ###
  3. Delete file ###.bak

Code:

File.Copy(filename, filename + ".bak");
TextWriter writer = new StreamWriter(filename);
writer.Write(content);
writer.Close();
File.Delete(filename + ".bak");

During deleting I got exception:

IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)

Size of both files is maximum few MB. And I checked - there is enough free space on disk (more than few GBs). What are possible reasons for that situations?

It's a desktop app (WPF), running on OS drive, on admin account.

c# .net file-io save