ImgSource为文件的物理存储路径。
if (System.IO.File.Exists(ImgSource)) //先判断文件是否真实存在
//生成临时文件名
string strTmpFile = Guid.NewGuid().ToString().Replace("-", "");
string strImageExtFileName = ImgSource;
strImageExtFileName = strImageExtFileName.Substring(strImageExtFileName.LastIndexOf("."));
strTmpFile += strImageExtFileName;
//生成临时路径
string strAppPath = AppDomain.CurrentDomain.BaseDirectory;
if(!Directory.Exists(strAppPath + "tmp"))
{
Directory.CreateDirectory(strAppPath+"tmp");
}
//复制图片文件
File.Copy(ImgSource,string.Format("{0}tmp\\{1}",strAppPath,strTmpFile));
}