Simple utility class to use when you need to store files
against an identity integer. Methods to map ids to web or file system paths are
provided. Temporary folder provided so large files can be submitted in advance
before final store filename assigned, like when getting an id from a database.
There are methods for UInt32 and UInt64. Use which ever
suits you. If you are using a standard Int32 (“int” in code) for your ids, then
the maximum value is 2,147,483,647 (0x7FFFFFFF).
If you are going to need higher ids, you can use UInt32 to
get double that, or a UInt64 that has a max value of 18,446,744,073,709,551,615
(0xFFFFFFFFFFFFFFFF).
Directories are balanced so no more than 65,535 (0xFFFF)
files or directories end up in any directory. This prevents strain on the file
system and explorer going into melt down.
Files are stored in the following way:
·
UInt32 StoreRoot\0123\01234567.dat
·
UInt64 StoreRoot\0123\4567\89AB\0123456789ABCDEF.dat
All filenames are either 8 or 16 long zero padded
hexadecimal. Directories are 4 long hexadecimal sections of the filename.
You have to store the extension yourself, it needs supplying
to the mapping methods.