There are times where we need to create unique identifiers to differentiate between resources or records without keeping an indexer. Provided they don't have to be globally unique and are created within a minimum of 100ms of each other, an alternative to the GUID may be to use the current time. This adds another piece of data with no additional cost: the time of (resource) creation is in the UID.
string fileName = DateTime.Now.Ticks.ToString() + ".zip"; // string of digits
string fileName = DateTime.Now.Ticks.ToString() + ".zip"; // string of digits
OR
string fileName = DateTime.Now.Ticks.ToString("x") + ".zip"; // alpha numeric string (hexadecimal)
Comments
Post a Comment