BEC2
BEC2

Reputation: 7

Creating folder with a different name each time

I have an asp.net c# web application which creates a folder.The web application includes some buttons to change sth in this folder.The web application is hosted at 2008 server. Now I want to make it multi user application. Different users should run this web application with different folder names and they can change something on the folder simultaneously. How to manage it?

Upvotes: 0

Views: 1848

Answers (2)

Robert Bolton
Robert Bolton

Reputation: 673

You can generate the folder name based on the current user's ID and a date time stamp. The resulting format would be "hsimpson_2013-11-23_12-23-12-AM" or something along these lines. That way you could always get a list of folders and sort by just the users whose names exist as part of the string or search folders based on a date/time.

Upvotes: 0

Dennis
Dennis

Reputation: 37780

Use Path.GetRandomFileName:

var folderName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(folderName);

Upvotes: 1

Related Questions