zoukankan      html  css  js  c++  java
  • 样式版本批量处理,使用文件修改最后日期作为版本号参数

    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();
    }
    }
    }

  • 相关阅读:
    递归的初步应用
    最大公约数与最小公倍数(低效)
    进制转换
    凸多边形的面积问题
    单词替换
    DNA排序
    字符串排序
    倒三角形
    韩信点兵
    oracle
  • 原文地址:https://www.cnblogs.com/liwp/p/7084856.html
Copyright © 2011-2022 走看看