上传文件,另存为物理文件方法

publicbool UploadImg(byte[] fileBytes,string path)
{
try
{
//文件保存目录路径
String savePath ="/upload/";
String dirPath
= Server.MapPath(savePath);

FileInfo ff
=new FileInfo(dirPath+path);
if (!ff.Directory.Exists) Directory.CreateDirectory(ff.DirectoryName);
System.IO.FileStream fs
= System.IO.File.Create(dirPath+path);
fs.Flush();
fs.Write(fileBytes,
0, fileBytes.Length);
fs.Close();
fs.Dispose();
returntrue;
}
catch
{
returnfalse;
}
}
原文地址:https://www.cnblogs.com/denglinhai/p/2098310.html