By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,977 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,977 IT Pros & Developers. It's quick & easy.

how to generate a unique working folder

P: n/a
hi,

i have a web service that has file operations on Windows OS, and there may
be a file concurrency issue if only one working directory e.g. c:\working

therefore, i want to have a unique sub directory for each request so as to
get rid of any file concurrency issue, e.g

c:\working\unique-identifier1 for Request #1
c:\working\unique-identifier1 for Request #2

of course, house-keep is then required.

any suggestions to do so?

thanks!
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,

Consider using a GUID for each working sub-directory:

eg.
System.Guid guid = System.Guid.NewGuid();
string strSubFolder = @"c:\working\" + guid.ToString();

Then you can use a collection (CollectionBase or your own CollectionBase
inherited class) with key = Request No. / ID and value = strSubFolder for
house-keeping.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
hi,

i have a web service that has file operations on Windows OS, and there may
be a file concurrency issue if only one working directory e.g. c:\working

therefore, i want to have a unique sub directory for each request so as to
get rid of any file concurrency issue, e.g

c:\working\unique-identifier1 for Request #1
c:\working\unique-identifier1 for Request #2

of course, house-keep is then required.

any suggestions to do so?

thanks!

Nov 16 '05 #2

P: n/a
1. any size limitation of GUID? how many GUID could be generated?
2. will it be overflow? or will it reuse the old GUID if all the values are
used?

thanks!

"mooni" <to*****@hotmail.com> wrote in message
news:41******@dnews.tpgi.com.au...
Hi,

Consider using a GUID for each working sub-directory:

eg.
System.Guid guid = System.Guid.NewGuid();
string strSubFolder = @"c:\working\" + guid.ToString();

Then you can use a collection (CollectionBase or your own CollectionBase
inherited class) with key = Request No. / ID and value = strSubFolder for
house-keeping.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
hi,

i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working
therefore, i want to have a unique sub directory for each request so as to get rid of any file concurrency issue, e.g

c:\working\unique-identifier1 for Request #1
c:\working\unique-identifier1 for Request #2

of course, house-keep is then required.

any suggestions to do so?

thanks!


Nov 16 '05 #3

P: n/a
> 1. any size limitation of GUID? how many GUID could > be generated?
2. will it be overflow? or will it reuse the old GUID if all the values
are used?
I'll quote directly from the .NET documentation:

"A GUID is a 128-bit integer (16 bytes) that can be used across all
computers and networks wherever a unique identifier is required. Such an
identifier has a very low probability of being duplicated."

The maximum number of possible unique GUID's is 2^128 or
3.4028236692093846346337460743177e+38. A new unique GUID is generated every
time you call the System.Guid.NewGuid() method.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:eX**************@TK2MSFTNGP14.phx.gbl... 1. any size limitation of GUID? how many GUID could be generated?
2. will it be overflow? or will it reuse the old GUID if all the values
are
used?

thanks!

"mooni" <to*****@hotmail.com> wrote in message
news:41******@dnews.tpgi.com.au...
Hi,

Consider using a GUID for each working sub-directory:

eg.
System.Guid guid = System.Guid.NewGuid();
string strSubFolder = @"c:\working\" + guid.ToString();

Then you can use a collection (CollectionBase or your own CollectionBase
inherited class) with key = Request No. / ID and value = strSubFolder for
house-keeping.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> hi,
>
> i have a web service that has file operations on Windows OS, and there may > be a file concurrency issue if only one working directory e.g. c:\working >
> therefore, i want to have a unique sub directory for each request so as to > get rid of any file concurrency issue, e.g
>
> c:\working\unique-identifier1 for Request #1
> c:\working\unique-identifier1 for Request #2
>
> of course, house-keep is then required.
>
> any suggestions to do so?
>
> thanks!
>
>



Nov 16 '05 #4

P: n/a
You can always check if the directory exist, if exists then generate
another guid.
On Wed, 19 Jan 2005 12:32:03 +0800, "Mullin Yu" <mu*******@ctil.com>
wrote:
1. any size limitation of GUID? how many GUID could be generated?
2. will it be overflow? or will it reuse the old GUID if all the values are
used?

thanks!

"mooni" <to*****@hotmail.com> wrote in message
news:41******@dnews.tpgi.com.au...
Hi,

Consider using a GUID for each working sub-directory:

eg.
System.Guid guid = System.Guid.NewGuid();
string strSubFolder = @"c:\working\" + guid.ToString();

Then you can use a collection (CollectionBase or your own CollectionBase
inherited class) with key = Request No. / ID and value = strSubFolder for
house-keeping.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> hi,
>
> i have a web service that has file operations on Windows OS, and theremay > be a file concurrency issue if only one working directory e.g.c:\working >
> therefore, i want to have a unique sub directory for each request so asto > get rid of any file concurrency issue, e.g
>
> c:\working\unique-identifier1 for Request #1
> c:\working\unique-identifier1 for Request #2
>
> of course, house-keep is then required.
>
> any suggestions to do so?
>
> thanks!
>
>



Nov 16 '05 #5

P: n/a
You can always check to see if the directory exist, if not then use
the new guid otherwise generate another one.

On Wed, 19 Jan 2005 12:32:03 +0800, "Mullin Yu" <mu*******@ctil.com>
wrote:
1. any size limitation of GUID? how many GUID could be generated?
2. will it be overflow? or will it reuse the old GUID if all the values are
used?

thanks!

"mooni" <to*****@hotmail.com> wrote in message
news:41******@dnews.tpgi.com.au...
Hi,

Consider using a GUID for each working sub-directory:

eg.
System.Guid guid = System.Guid.NewGuid();
string strSubFolder = @"c:\working\" + guid.ToString();

Then you can use a collection (CollectionBase or your own CollectionBase
inherited class) with key = Request No. / ID and value = strSubFolder for
house-keeping.

HTH

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> hi,
>
> i have a web service that has file operations on Windows OS, and theremay > be a file concurrency issue if only one working directory e.g.c:\working >
> therefore, i want to have a unique sub directory for each request so asto > get rid of any file concurrency issue, e.g
>
> c:\working\unique-identifier1 for Request #1
> c:\working\unique-identifier1 for Request #2
>
> of course, house-keep is then required.
>
> any suggestions to do so?
>
> thanks!
>
>



Nov 16 '05 #6

P: n/a
"qwerty" <no@email.net> wrote in message
news:lk********************************@4ax.com...
You can always check if the directory exist, if exists then generate
another guid.


Probably not worth it in final analysis. AFAIK GUID's are pretty much
guaranteed to be unique in time and space. Considering that GUIDs would be
sufficient to have a million for each cubic lightyear in the entire
universe, you can see that the solution space is quite large (to say the
least). Then, the GUID generation algorithm is designed to avoid collisions.
In fact, IIRC, you could only get a GUID collision on current hardware
before the heat death of the universe if the two machines shared the same
MAC address. As for the on the same machine, I'm pretty sure you'll watch
the Gnab Big before you got a collision.

Putting in checking code for such an infinitesimally small chance is
probably just a waste of processor cycles. If it makes you happier to put
the check in though, go ahead, since I doubt the performance impact will
have any realistic impact on your code.

As you can see, I'm a bit conflicted as to how I'd approach this ;D
Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.