I was dealing with a prepending problem and suddenly leads me to think about this question....
Maybe not only related to FileStream, I want to know how we actually appends binary into a file physically work.
I guess my question will leads two quetions:
- How the hard disk memory is structured?
- How file write into physical memory?
Say I have a Text File, contains "ABCDEF", so in physical memory (in hard disk), the memory should contains the binary of the letters "ABCDEF" with file header binary etc (actually no header for plain text file?)....
So will be something like this in physically 6 bytes, orders depends on the processor type:
A B C D E F 01000001 01000010 01000011 01000100 01000101 01000110
Say when we want to appends a letter 'G' in the file, so the file will contains 7 bytes:
A B C D E F G 01000001 01000010 01000011 01000100 01000101 01000110 01000111
Both file size in disk physically should 4.00KB.
Because when we write the letter G, is still not excess the 4.00KB, so we have space to write into the 4.00KB memory space.
But when we will appends more things in the file, when execess the 4.00KB will be using 8.00KB.
How does the binary that excess the 4.00KB write into the disk memory?
Does it write a pointer or something to somewhere and declare an index in the disk memory and write the excessing binary into the new memory address?