How to create unique file names?
- From: "Brett" <no@xxxxxxxx>
- Date: Tue, 10 May 2005 12:18:35 -0400
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
.
- Follow-Ups:
- Re: How to create unique file names?
- From: mdb
- Re: How to create unique file names?
- From: Cor Ligthert
- Re: How to create unique file names?
- From: Steve Walker
- Re: How to create unique file names?
- From: Paul Tomlinson
- Re: How to create unique file names?
- Prev by Date: reference a dll in GAC from command line
- Next by Date: How to find network connection status ?
- Previous by thread: reference a dll in GAC from command line
- Next by thread: Re: How to create unique file names?
- Index(es):
Relevant Pages
|