zoukankan      html  css  js  c++  java
  • 利用Resgen.exe 批量生成resources文件

    Resgen.exe(资源文件生成器) 
    您可以直接如图操作


    转换时在 文本中先写好要转换的文件然后 全选 复制到控制台中
    Filename.resx 要转换的文件 ResName1.resources 生成的resources 文件名

    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这样的命令一不小心还可能编辑错误,

    答:方法肯定是有的!!!

    右键 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 FilesMicrosoft Visual Studio 10.0VCvcvarsall.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;
            }

     

     
  • 相关阅读:
    BEA WebLogic JRockit的使用和性能调优
    项目调优笔记
    设计资源收集
    2011年推荐WEB在线应用
    Oracle10g调优:Oracle10g AWR使用方法及分析
    谈数据库的性能优化
    EXTJS双击关闭标签代码
    chrome插件API协议(Extensions Context Menu API Proposal)
    ASH Report For AWDDB/awddb
    java内存查看与分析
  • 原文地址:https://www.cnblogs.com/mr-lee1976/p/4831121.html
Copyright © 2011-2022 走看看