views:

156

answers:

2

Risk Factors for File Fragmentation include mostly full Disks and repeated file appends. What are other risk factors for file fragmentation? How would one make a program using common languages like C++/C#/VB/VB.NET to work with files & make new files with the goal of increasing file fragmentation?

WinXP / NTFS is the target

Edit: Would something like this be a good approach? Hard Drive free space = FreeMB_atStart

  • Would creating files of say 10MB to fill 90% of the remaining hard drive space
  • Deleting every 3rd created file
  • making file of size FreeMB_atStart * .92 / 3
+2  A: 

This should achieve at least some level of fragmentation on most file systems:

1) Write numerous small files.

2) Delete some at random.

3) Writing a large file, byte-by-byte.

Writing it byte-by-byte is important because otherwise if the file system is intelligent, it can just write the large file to a single contiguous place.

Jamer
So out using C++ and fstream be recommended for control? To write byte-by-byte, would you just use a outputFile.flush after each byte?
ExcelCyclist
Well, it would be much easier if you didn't use a buffered output stream in the first place. What about using putch()?
Jamer
Still won't help. Too many operating systems just won't bother. Also, you can write 512 bytes at a time. No OS uses a smaller allocation unit anyway.
MSalters
A: 

Another possibility would be to write several files simultaneously byte-by-byte. This would probably have more effect.

Jamer