C#代码修改.resource文件为.resx文件

static void Convert(string resourcesFilePath)
        {
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe ";

            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            //p.StartInfo.CreateNoWindow = false;


            p.Start();

            //+ '"' + '"' + can replace
            p.StandardInput.WriteLine("%comspec% /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\Tools\\VsDevCmd.bat\"");

            Console.WriteLine(resourcesFilePath);
            p.StandardInput.WriteLine(" resgen " + resourcesFilePath + " " + resourcesFilePath.Replace(".resources", ".resx"));

            p.StandardInput.WriteLine("  ");
            p.StandardInput.Flush();
            p.StandardInput.WriteLine(" exit ");

            //Exit cmd.exe
            p.StandardInput.WriteLine(" exit ");
            p.WaitForExit();
            var s = p.StandardOutput.ReadToEnd();
            Console.WriteLine("s_________________________________________________SSSSSSSSSSSSSSSSSSSSSSSSSS");
            Console.WriteLine(s);
            p.Close();


        }

 

posted @ 2021-03-15 10:05  灰主流  阅读(590)  评论(0编辑  收藏  举报