Advertisement
KvanTTT

Multithreading collision

Nov 29th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. private static string GenerateFileName2(CloudBlobDirectory container, string uploadFilePrefix)
  2. {
  3.     DateTime now = DateTime.Now;
  4.     string nowString = now.ToString(CultureInfo.CurrentCulture.DateTimeFormat.SortableDateTimePattern);
  5.     string result = uploadFilePrefix + nowString + "_000";
  6.  
  7.     var blob = container.GetBlockBlobReference(result);
  8.     int i = 1;
  9.     while (blob.Exists())
  10.     {
  11.         result = uploadFilePrefix + nowString + "_" + (i++).ToString("000");
  12.         blob = container.GetBlockBlobReference(result);
  13.     }
  14.  
  15.     return result;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement