TranslateTool.RunProgram.FindSDKTool C# (CSharp) Method

FindSDKTool() public static method

public static FindSDKTool ( string exeName ) : string
exeName string
return string
        public static string FindSDKTool(string exeName)
        {
            string[] filenames = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\Microsoft SDKs\Windows", exeName, SearchOption.AllDirectories);
            Array.Sort(filenames);
            if (filenames.Length > 0)
                return filenames[filenames.Length - 1];
            else
                return null;
        }

Usage Example

Example #1
0
        private void dialogEditorButton_Click(object sender, EventArgs e)
        {
            if (listViewStrings.SelectedItems.Count > 0)
            {
                ListViewItem item = listViewStrings.SelectedItems[0];
                LocString    str  = (LocString)item.Tag;

                Save();

                string winResExe = RunProgram.FindSDKTool("winres.exe");
                if (winResExe == null)
                {
                    MessageBox.Show(@"Cannot find al.exe in the Windows SDK. Make sure the Windows SDK is installed in c:\Program Files\Microsoft SDKs\Windows");
                }
                else
                {
                    // The unlocalized file must be copied to the same directory as the localized for winres to work.
                    string resXFileName          = str.File.LocalizedFileName;
                    string resXUnlocalized       = str.File.NonLocalizedFileName;
                    string resXCopiedUnlocalized = Path.Combine(Path.GetDirectoryName(resXFileName), Path.GetFileName(resXUnlocalized));
                    bool   copy = !string.Equals(resXUnlocalized, resXCopiedUnlocalized, StringComparison.InvariantCultureIgnoreCase);

                    if (copy)
                    {
                        File.Copy(resXUnlocalized, resXCopiedUnlocalized, true);
                    }

                    Enabled = false;
                    try {
                        RunProgram runProgram = new RunProgram();
                        runProgram.Run(winResExe, Path.GetFileName(resXFileName), Path.GetDirectoryName(resXFileName));
                    }
                    finally {
                        Enabled = true;
                        Activate();
                    }

                    if (copy)
                    {
                        File.Delete(resXCopiedUnlocalized);
                    }

                    resourceDirectory.ReadResources();
                    PopulateListView();
                }
            }
        }
All Usage Examples Of TranslateTool.RunProgram::FindSDKTool