mirror of
https://github.com/quasar/Quasar.git
synced 2026-10-22 00:15:56 +08:00
21 lines
652 B
C#
21 lines
652 B
C#
using System;
|
|
using System.Text;
|
|
|
|
namespace xClient.Core.Helper
|
|
{
|
|
public static class FileHelper
|
|
{
|
|
private const string CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
private static readonly Random _rnd = new Random(Environment.TickCount);
|
|
|
|
public static string GetRandomFilename(int length, string extension = "")
|
|
{
|
|
StringBuilder randomName = new StringBuilder(length);
|
|
for (int i = 0; i < length; i++)
|
|
randomName.Append(CHARS[_rnd.Next(CHARS.Length)]);
|
|
|
|
return string.Concat(randomName.ToString(), extension);
|
|
}
|
|
}
|
|
}
|