1

Is it possible to create a file on a disk which is full??

Does creation of the file take any space??

Basically I am seeing a case where C# has created but failed to write anything whhich I think points to a full disk.

Does anyone know whether creating a file on a full disk will fail or not??

2
  • You might ask this question on StackOverflow instead. Jan 11, 2010 at 10:06
  • Doesn't the file creation call return an error that can be trapped and read if there's a full filesystem? From your description there could also be permission errors, as it's possible to have permission to create a file but not modify it. Jan 11, 2010 at 12:40

2 Answers 2

4

It depends on the filesystem.

The vast majority of filesystems will allow a file of zero length to be created even if there are no free block on the disc as no blocks need to be allocated at that point, unless the directory entry's blocks are full in which case you will get a "no space" error as it tries to add a new block to the directory listing. Certainly NTFS will works way. Some filesystems allow the content of small files to be stored in the the directory entry itself or other pre-allocated structures - so you might be able to create small-but-not-zero-length file on a seemingly full filesystem.

Some older filesystems (FAT*?) will always allocate the first block of the file at creation time as their spec doesn't allow for files with no blocks allocated so these will always fail to create a file on a full device.

0

Yes, because when you create a file that has no data, it only resides in the Master File Table (MFT). If the file is 1 kbyte or less, it only exists in the MFT. It's possible for the disk to report no free space, but the MFT may have enough free space to create a file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .