Reputation: 179
HI, I need to create unique folder name to be created in the user local App data path, I cannot generate folder names using MD5 and other algorithms as the result has in valid characters for folder name. Is there a way from which I can generate folder names from a given file path or name ?
Upvotes: 2
Views: 2054
Reputation: 1047
How fast are you willing to get those folders created ? I'm saying this because you could use the system time, in milliseconds, to name those unique folders. If you want to avoid the possibility of having two or more folders on the very same time, concatenate some string at the end.
Upvotes: 0
Reputation: 53944
Why is an MD5 like
A4-B7-81-7F...
invalid? Have a look at the BitConverter-class
Upvotes: 4
Reputation: 27499
Can't you just use a Guid?
String folderName = Guid.NewGuid().ToString();
Upvotes: 10
Reputation: 25460
Why not just remove, replace or encode those invalid characters as valid ones?
Upvotes: 0