我们将项目中的图像文件夹携带到IIS应用程序池中,这是另一个返回快速响应的服务器。现在,当我们要下载图像时,由于携带其他服务器,找不到文件夹并出现错误。当images文件夹位于项目文件夹中时,它可以正常工作。该如何处理?为新请求创建新的虚拟路径? 寻求建议
using (var ms = new MemoryStream())
{
using (var ziparchive = new ZipArchive(ms, ZipArchiveMode.Create, true))
{
for (int i = 0; i < ticket.Count(); i++)
{
string filepath;
string path = string.Empty;
var extension = Path.GetExtension(ticket[i].Value);
if (videoExtensions.Contains(extension))
{
filepath = "/files/ticketvideo/" + ticket[i].Value;
path = AppDomain.CurrentDomain.BaseDirectory + filepath.Substring(1).Replace("/", "\\");
}
else
{
filepath = "~/images/adminticket/" + ticket[i].Value;
path=Server.MapPath(filepath.Replace("/", "\\"));
/*System.Web.Hosting.HostingEnvironment.MapPath(filepath.Replace(" / ", "\\"));*/
}
try
{
ziparchive.CreateEntryFromFile(path,ticket[i].Value);
}
catch (Exception ex)
{
}
}
}
return File(ms.ToArray(), "application/zip", string.Format("{0}.zip",Id));