[英]Combining directory files in asp.net with custom-built process
I have two directories that contain files. 我有两个包含文件的目录。 I want to combine all these files into one. 我想将所有这些文件合并为一个。 I already know about native minification but I don't want to do that because I need something custom-built (it's a single-page app and there are several conditions on which files to include into which output based on the type of users and a few other conditions). 我已经知道本机缩小了但我不想这样做,因为我需要一些定制的东西(它是一个单页面的应用程序,并且有几个条件,哪些文件包含在哪些输出中,基于用户类型和其他一些条件)。
Let's say that in folder MyScripts
I have files Script1.js, Script2.js .... Script14.js
. 假设我在文件夹MyScripts
有文件Script1.js, Script2.js .... Script14.js
。 I want to use a string builder to open and append these files and then create a consolidated MyFullScript.js
file that's saved into the MyScripts
folder. 我想使用字符串构建器打开并附加这些文件,然后创建一个整合的MyFullScript.js
文件,该文件保存在MyScripts
文件夹中。 I'm not sure where to look for this, what are some ways of doing this? 我不知道在哪里寻找这个,有什么方法可以做到这一点?
Thanks. 谢谢。
Why not write a quick function on c# to concatenate everything as so: 为什么不在c#上编写一个快速函数来连接所有内容,如下所示:
DirectoryInfo info = new DirectoryInfo ("c:\\temp"); //Path to JS files
StringBuilder sb = new StringBuilder();
foreach(var item in info.GetFiles("*.js"))
{
sb.Append(File.ReadAllText(item.FullName));
sb.Append(Environment.NewLine);
}
Now sb
has all your scripts concatenated; 现在sb
已将所有脚本连接起来; you can save the string to a new .js
file if that's what you need. 您可以将字符串保存到新的.js
文件中,如果这是您需要的。
Hi this may or may not help, came across it when implementing jQuery FileUpload by blu-imp. 嗨,这可能会有所帮助,也可能没有帮助,在blu-imp实现jQuery FileUpload时遇到了它。 Anyway provides bundling and minification services as required, seemed quite configurable to me, more so than the native stack anyhow and may provide the granularity you need! 无论如何,根据需要提供捆绑和缩小服务,对我来说似乎是可配置的,无论如何都比原生堆栈更多,并且可能提供您需要的粒度!
http://clientdependency.codeplex.com/ http://clientdependency.codeplex.com/
After re-reading your post I think this may well be of help, especially as the source code is available on code-plex so I figure this may provide 80% of the functionality you need whereby you may have to fork it and add a custom 20% to get it to how you need it! 在重新阅读你的帖子后,我认为这可能会有所帮助,特别是因为源代码可以在代码复制中使用,所以我认为这可能提供你需要的80%的功能,你可能需要分叉它并添加一个自定义20%可以满足您的需求!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.