I need an algorithm to generate unique file name. I cannot use standard Win32 function GetTempFileName because of it allows create not more than 65536 filenames with the given prefix. I the limit need much more than 65536.
Thanks in advance
Printable View
I need an algorithm to generate unique file name. I cannot use standard Win32 function GetTempFileName because of it allows create not more than 65536 filenames with the given prefix. I the limit need much more than 65536.
Thanks in advance
Is that limit documented anywhere?
Take any of the File name and add a int value to your File name . Store the int value Somewhere in Registry and When Ever you create a new File read the registry Pick Old int value from registry increment the counter and concanate it with your File name .noe Replace old int value to new one and write it back to your registry.
Filename = Filename + some int value;
now always increment the value and write new name to registry
Thanx
And that will create an unique name? Have you thought of other application who can by chance create same name you might use next?Quote:
Originally Posted by humptydumpty
That is the Concept Behind Creating a new File name everytime have a loo for Microsoft word Example and it's good if you Check Word how it created new names always.apart from this no commentQuote:
Originally Posted by Krishnaa
Thanx
Well, that not the complete logic, there is more which checks for existance of file and then again increment/something untill it gets unique name. And yes, its not needed to involve registry there, very easily you can take current timestamp, and start hitting for unique names.Quote:
Originally Posted by humptydumpty
i think you should keep track of the counter it's my openion .otherwise you have to do a lots of work to get the File Counter name . Remaining is upto you how you are going to implement .that's what i think .you can utilize some other technique it's not compelsory that be both will go with same logic.
Thanx
It is obvious from description of the function. It creates filename of the following type:Quote:
Originally Posted by Krishnaa
<pre><uuuu>.TMP
where <uuuu> is hexadecimal value. Thus, largest possible number is 65536.
According to the MSDN documentation, uuuu is the hexadecimal representation of uUnique, which is a UINT. Thus I believe you'll find that the maximum value is 0xFFFFFFFF or 4294967295. It's probably a shortened representation in the hex format (not always 8 characters).Quote:
Originally Posted by KellyLynch
Hope that helps.