|
Posted on
2009-11-02 16:44
X龙
阅读( 353)
评论()
编辑
收藏
举报
Code /// <summary> /// 生成指定长度随机字符串(由大写字母组成) /// </summary> public static string GenerateRandomFilename(int len) { char[] chars = new char[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N', 'O','P','Q','R','S','T','U','V','W','X','Y','Z'}; Random random = new Random(DateTime.Now.Millisecond); string fileName = String.Empty; for (int i = 0; i < len; i++) { int index = random.Next(0, 26); fileName += chars[index]; } return fileName; }
|