예제 #1
0
        public static string GetUniqueFileName(string directory, string filename, out string filepath)
        {
            using (var crypto = new Cryptographer())
            {
                bool   unique       = false;
                string origFilename = filename;
                do
                {
                    filename = string.Format("{0}-{1}", crypto.CreateUniqueKey(4), filename);
                    filepath = Path.Combine(directory, filename);

                    if (!File.Exists(filepath))
                    {
                        unique = true;
                    }
                } while (!unique);
                return(filename);
            }
        }