liwp

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace CRM3.Common
{
public class AutoVersion
{
private static string SetVersion(string filePath)
{
string verFilePath = filePath;
string serverPath = HttpContext.Current.Server.MapPath(filePath);
if (File.Exists(serverPath))
{
verFilePath = filePath + "?" + File.GetLastWriteTime(serverPath).ToString("yyMMddHHmmss");
//verFilePath = filePath.Insert(filePath.LastIndexOf(\'.\'),
// string.Concat(".", File.GetLastWriteTime(serverPath).ToString("yyMMddHHmmss")));
}
return verFilePath;
}

public static string CssLink(params string[] filePath)
{
var sb = new StringBuilder();
Array.ForEach(filePath, f => sb.AppendLine(string.Format(@"<link rel=""stylesheet"" type=""text/css"" href=""{0}"" />",
SetVersion(f))));
return sb.ToString();
}
public static string JavaScriptLink(params string[] filePath)
{
var sb = new StringBuilder();
Array.ForEach(filePath, f => sb.AppendLine(string.Format(@"<script type=""text/javascript"" src=""{0}""></script>",
SetVersion(f))));
return sb.ToString();
}
}
}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-01-18
  • 2021-12-03
  • 2021-07-05
  • 2021-12-23
猜你喜欢
  • 2021-09-17
  • 2021-08-12
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-01-02
  • 2021-08-08
相关资源
相似解决方案