利用Resgen.exe 批量生成resources文件
2014-01-10 16:20
573 查看
Resgen.exe(资源文件生成器)
您可以直接如图操作
转换时在 文本中先写好要转换的文件然后 全选 复制到控制台中
Filename.resx 要转换的文件 ResName1.resources 生成的resources 文件名
eg:
resgen E:\Filename1.resx e:\ResName1.resources
resgen E:\Filename2.resx e:\ResName2.resources
resgen E:\Filename3.resx e:\ResName3.resources
resgen E:\Filename4.resx e:\ResName4.resources
resgen E:\Filename5.resx e:\ResName5.resources
...................
这种看起来似乎很笨,但是也可以行的通,只是会比较麻烦.
每次批量转换的时候,都得先到文本中编辑一堆 resgen E:\Filename1.resx e:\ResName1.resources这样的命令一不小心还可能编辑错误,
那能否用代码调用Resgen.exe呢? 答:方法肯定是有的!!!
如下图所示:
右键 visual studio 命令提示(2010) 快捷方式 ,选择属性, ,复制起始位置: 你会发现 目标调用的是 ..\VC
下的一个批处理文件;
验证:
当我将 图片中 属性 =》 目标 文本框中的命令 赋值在在cmd中时发现 看红色部分!!!
这样的话,就happy了,我们可以通过代码方式用Process去启动 Resgen.exe
代码说明:
ArrayList 存放的是所有要转换的resx文件
resPath[0]="E:\Filename1.resx";
resPath[1]="E:\Filename2.resx";
...
为了避免手动向ArrayList 中赋值,可以在e:新建resxFile文件夹 将.resx存放e:\\resxFile这个里面然后遍历这个文件夹,for循环到ArrayList 中
特别注意:p.StandardInput.WriteLine("exit");要执行两次;
(
话说某人就因为只执行了一次,整了几天都没有找到原因)
ResxToRes
转自:http://music.573114.com/Blog/Html/E5A1/783006.html
资源文件生成器将文本(.txt 或 .restext)文件和基于 XML 的资源格式 (.resx) 文件转换为公共语言运行时二进制 (.resources) 文件,后者可嵌入到运行时二进制可执行文件中或编译成附属程序集。 上面是MSDN对Resgen.exe的描述.
您可以直接如图操作
转换时在 文本中先写好要转换的文件然后 全选 复制到控制台中
Filename.resx 要转换的文件 ResName1.resources 生成的resources 文件名
eg:
resgen E:\Filename1.resx e:\ResName1.resources
resgen E:\Filename2.resx e:\ResName2.resources
resgen E:\Filename3.resx e:\ResName3.resources
resgen E:\Filename4.resx e:\ResName4.resources
resgen E:\Filename5.resx e:\ResName5.resources
...................
这种看起来似乎很笨,但是也可以行的通,只是会比较麻烦.
每次批量转换的时候,都得先到文本中编辑一堆 resgen E:\Filename1.resx e:\ResName1.resources这样的命令一不小心还可能编辑错误,
那能否用代码调用Resgen.exe呢? 答:方法肯定是有的!!!
如下图所示:
右键 visual studio 命令提示(2010) 快捷方式 ,选择属性, ,复制起始位置: 你会发现 目标调用的是 ..\VC
下的一个批处理文件;
验证:
当我将 图片中 属性 =》 目标 文本框中的命令 赋值在在cmd中时发现 看红色部分!!!
这样的话,就happy了,我们可以通过代码方式用Process去启动 Resgen.exe
代码说明:
ArrayList 存放的是所有要转换的resx文件
resPath[0]="E:\Filename1.resx";
resPath[1]="E:\Filename2.resx";
...
为了避免手动向ArrayList 中赋值,可以在e:新建resxFile文件夹 将.resx存放e:\\resxFile这个里面然后遍历这个文件夹,for循环到ArrayList 中
特别注意:p.StandardInput.WriteLine("exit");要执行两次;
(
话说某人就因为只执行了一次,整了几天都没有找到原因)
private static string ResxToRes(ArrayList ResxPath) { //ResxFile 是一个文件夹,用来存放 需要转换的.resx 文件 string s = ""; Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); // + '"' + '"' + 可以用 \"\" 替换 p.StandardInput.WriteLine("%comspec% /k " + '"' + '"' + @"d:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" + '"' + '"' + " x86 "); for (int i = 0; i < ResxPath.Count; i++) { string Filename = ResxPath[i].ToString(); string ResName = //根据需要写相应算法生成文件名; //resgen E:\Filename1.resx e:\ResName1.resources p.StandardInput.WriteLine("resgen " + Filename + ""+"e:\\"+ResName+".resources"); p.StandardInput.WriteLine(" "); } //此处要exit两次 //退出visual studio 到 cmd.exe p.StandardInput.WriteLine("exit"); //退出cmd.exe p.StandardInput.WriteLine("exit"); p.WaitForExit(); s = s + p.StandardOutput.ReadToEnd(); p.Close(); return s; }
ResxToRes
转自:http://music.573114.com/Blog/Html/E5A1/783006.html
相关文章推荐
- 利用Resgen.exe 批量生成resources文件
- 利用Resgen.exe 批量生成resources文件
- 利用Resgen.exe 批量生成resources文件
- ResGen.exe 生成resources文件方法 [转]
- java利用exe4j生成exe可执行文件
- VC6.0利用CreateProcess创建子进程,MFC调用Win32生成的.exe文件为例
- java中如何利用JSmooth生成EXE文件
- windows下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
- linux(以ubuntu为例)下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
- java--利用exe4j生成.exe的可执行文件
- 利用dos编写能生成EXE文件,并运行该文件,显示结果为:HOW ARE YOU。
- 利用Eclipse和JSmooth生成java EXE可执行文件 (转)
- java--利用exe4j生成.exe的可执行文件
- 利用Eclipse和JSmooth生成java EXE可执行文件
- 利用 uic.exe 手动生成ui头文件
- linux(以ubuntu为例)下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
- 利用nw.js打包生成exe文件
- 利用IDEA和exe4j生成exe文件及资源文件和so、dll文件的放置
- 利用Eclipse和JSmooth生成java EXE可执行文件
- java--利用exe4j生成.exe的可执行文件