Exemple #1
0
        public static string GetRandomFileName()
        {
            byte[] numArray = new byte[10];
            RNGCryptoServiceProvider cryptoServiceProvider = (RNGCryptoServiceProvider)null;

            try
            {
                cryptoServiceProvider = new RNGCryptoServiceProvider();
                cryptoServiceProvider.GetBytes(numArray);
                char[] charArray = Path.ToBase32StringSuitableForDirName(numArray).ToCharArray();
                int    index     = 8;
                int    num       = 46;
                charArray[index] = (char)num;
                int startIndex = 0;
                int length     = 12;
                return(new string(charArray, startIndex, length));
            }
            finally
            {
                if (cryptoServiceProvider != null)
                {
                    cryptoServiceProvider.Dispose();
                }
            }
        }
Exemple #2
0
        public static string GetRandomFileName()
        {
            byte[] numArray = new byte[10];
            RNGCryptoServiceProvider cryptoServiceProvider = (RNGCryptoServiceProvider)null;

            try
            {
                cryptoServiceProvider = new RNGCryptoServiceProvider();
                cryptoServiceProvider.GetBytes(numArray);
                char[] chArray = Path.ToBase32StringSuitableForDirName(numArray).ToCharArray();
                chArray[8] = '.';
                return(new string(chArray, 0, 12));
            }
            finally
            {
                if (cryptoServiceProvider != null)
                {
                    cryptoServiceProvider.Dispose();
                }
            }
        }