新建商品时,导入商品,随机文件名称的形成
//随机文件名称
public static string getRandomFileName(string fileName)
{
if (!string.IsNullOrEmpty(fileName))
{
System.Threading.Thread.Sleep(100);
string fileType = fileName.Substring(fileName.LastIndexOf("."));
System.Random rand = new System.Random();
DateTime now = DateTime.Now;
string str = "";
str += now.Year.ToString();
str += now.Month.ToString();
str += now.Day.ToString();
str += now.Hour.ToString();
str += now.Minute.ToString();
str += now.Second.ToString();
str += rand.Next(0, 1000);
return str + fileType;
}
else
{
return "";
}
}