How to create unique file names?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I need to create unique file names while in a loop. Each interaction will
produce a file name. Also, there may be 10 threads, each with its own loop
producing files, all going at the same time. The files are actually images
being created by a special printer driver.

I thought using a long date would be good. However, I can't find how to
include milliseconds, which is critical. This is the closest I could find:
System.DateTime.Now.Millisecond. Also, I will need to append a random
number to the date, which should ensure uniqueness.

I want to remove all spaces, semicolons, and slashes. This means three
lines of code to perform a Replace() on the same variable. Is there another
way to do this?

Any comments on a completely different approach to producing these unique
names is welcome. Dates aren't necessary. I wasn't sure if a random number
has the probability of coming up again at some point. That's why I chose a
mixture of date and random number.

Thanks,
Brett


.



Relevant Pages

  • Re: Hrs of work on regex: please help
    ... You don't need to name this loop because you are not using any loop ... If you don't use forward slashes to delimit ... your substitution strings, you won't have to escape the forward slashes ...
    (comp.lang.perl.misc)
  • Re: what does two semicolns ;; do
    ... what is the function of the two semicolons? ... I've tried to google it but the text filter seems to remove the ... Look up a for loop in the PHP doc. ... the expressions are null. ...
    (comp.lang.php)
  • Re: Help understanding this use of while
    ... Barry Schwarz writes: ... that the while loop will just occur once but then why use a while loop ... above (i.e. to watch his of her semicolons like a hawk) then what is ... while trick is to introduce a block that is ...
    (comp.lang.c)
  • Re: for loop
    ... The C-style forloop requires semicolons, not commas. ...
    (comp.lang.perl.misc)
  • Re: what does two semicolns ;; do
    ... what is the function of the two semicolons? ... statement in that loop are the empty statement. ... Ridiculous usage of the language construct... ... Sincerely Yours, AnrDaemon ...
    (comp.lang.php)