I made sequence of operations (on local disk):
- Copy file to ###.bak
- Save file to ###
- 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.
System.IO.File.Delete?System.IO.File.Deletefilenameis the file you think it is. (3) try your code with really small files (e.g. <1KB in size) and see if the error still happens (4) try to copy the file manually using explorer or cmd.exe/copy and see if the error still happens.