如何从" powershell"中的C#.resources.dll获取资源价值。

时间:2017-09-11 12:19:42

标签: powershell powershell-v2.0 powershell-v3.0

在Powershell实施期间,我想从语言特定资源dll获取资源值,资源文件在" en-US"," de-DE",...中可用。 。文件夹

1 个答案:

答案 0 :(得分:0)

以下是de-De资源阅读的示例powershell脚本

$de_DE_ResourceAssembly = [Reflection.Assembly]::LoadFile("<full Path to resources.dll e.g ...\bin\de-DE\snapin.resources.dll >")
$manifestName =  $de_DE_ResourceAssembly.GetManifestResourceNames()
$rm = new-object -typename System.Resources.ResourceManager -ArgumentList 
$manifestName.Replace('.resources',''), $de_DE_ResourceAssembly
$culture = New-Object System.Globalization.CultureInfo("de-DE")
$rm.GetString("<Resource key>",$culture)