/// <summary> /// 读取js文件内容并压缩 /// </summary> /// <param name="filePathlist"></param> /// <returns></returns> public static string ReadJSFile(string[] filePathlist) { StringBuilder jsStr = new StringBuilder(); try { string rootPath = Assembly.GetExecutingAssembly().CodeBase.Replace("/bin/cx.Util.DLL", "").Replace("file:///", ""); foreach (var filePath in filePathlist) { string path = rootPath + filePath; if (DirFileHelper.IsExistFile(path)) { string content = File.ReadAllText(path, Encoding.UTF8); if (Config.GetValue("JsCompressor") == "true") { content = javaScriptCompressor.Compress(content); } jsStr.Append(content); } } return(jsStr.ToString()); } catch (Exception) { return(""); } }
/// <summary> /// 读取对应文件 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static string Read(string filePath) { StringBuilder str = new StringBuilder(); try { string rootPath = Assembly.GetExecutingAssembly().CodeBase.Replace("/bin/cx.Util.DLL", "").Replace("file:///", ""); string path = rootPath + filePath; if (DirFileHelper.IsExistFile(path)) { string content = File.ReadAllText(path, Encoding.UTF8); str.Append(content); } return(str.ToString()); } catch (Exception) { return(""); } }