标签:
public void FileUpLode(HttpPostedFileBase FileBase, string ClyID, string FileType)
{
var HFilename = "";
if (!string.IsNullOrEmpty(FileBase.FileName)) //判断文件是否存在
{
string dir = EFWebCenterExhibitor.Models.Helper.ERoot + "/DataFile/upload/ActorFile/"; //要保存文件的地址
StringBuilder File = new StringBuilder();
if (!Directory.Exists(dir)) //文件是否存在
{
Directory.CreateDirectory(dir); //创建文件夹
}
string _tempFileName = FileBase.FileName.Substring(0, FileBase.FileName.LastIndexOf(".") - 1);//文件名
string _tempFileNameHZ = FileBase.FileName.Substring(FileBase.FileName.LastIndexOf("."));//后缀名
//保存原图
string randomName = Helper.GetRandomFildName("");
string tempFileName = RandCode(10) + DateTime.Now.ToString("yyyyMMddHHmmss") + _tempFileNameHZ; //FileBase.FileName;
string fileName = dir + tempFileName; //FileBase.FileName;
FileBase.SaveAs(fileName);
}
}
标签:
原文地址:http://www.cnblogs.com/mys0226/p/5756402.html