最近做了一个这样的需求,花了点时间,所以记录下来,有需要的朋友可以直接用
/// <summary>
/// 导出图片
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ExportImg(string departmentId, string keyword)
{
UserService userService = new UserService();
DataTable exportTable = userService.GetExportList(departmentId, keyword); //获取要导出的图片
string virtualPath = "/Resource/ImagesDowload/Images/";
string fullFileName = this.Server.MapPath(virtualPath);
//创建文件夹
string pathDic = Path.GetDirectoryName(fullFileName);
if (!Directory.Exists(pathDic))
{
Directory.CreateDirectory(pathDic);
}
foreach (DataRow item in exportTable.Row