对上传的附件名加密
Hashtable htFileNames = new Hashtable();
string fullFileName = string.Empty; //文件全名(包括路径)
string fileName = string.Empty; //文件名
string encodeFileName = string.Empty; //文件名加密串
string extName = string.Empty; //文件扩展名
bool imgExisted = false; // 图片
bool fileExisted = false; // 附件
string imgFormat = ".jpg;.bmp;.gif;.png;.tif;.tiff;.jpeg";
for(int attInx =1;attInx<=5;attInx++)
{
HtmlInputFile upload = (HtmlInputFile)this.FindControl("File" + attInx.ToString());
if(upload!=null && upload.PostedFile!=null && upload.PostedFile.FileName.Length>0){
fullFileName = upload.PostedFile.FileName;
fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
encodeFileName = PubType.CleanStringRegex(EncryptionUtil.EncryptData("",fileName.Substring(0,fileName.LastIndexOf('.')-1)));
extName = fileName.Substring(fileName.LastIndexOf('.'));
if(imgFormat.IndexOf(extName.ToLower())>-1){
imgExisted = true;
}else{
fileExisted = true;
}
upload.PostedFile.SaveAs(Server.MapPath(path)+"\\"+encodeFileName + extName);
htFileNames.Add(fileName,encodeFileName + extName);
}
}