- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 powershell 获取文件的文件版本。如果我右键单击该文件并查看版本,它会显示一个值。这是我正在尝试的方式:
$path = "MSDE2000A";
$info = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path);
这是它抛出的异常信息:
Exception calling "GetVersionInfo" with "1" argument(s): "MSDE2000A.exe"
At line:1 char:58
+ $f = [system.diagnostics.fileversioninfo]::getversioninfo <<<< ("MSDE2000A.exe")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
我检查过的每个文件都有相同的结果。但是,如果我的路径是 c:\windows\notepad.exe(如在 example 中),它会按预期工作。怎么回事?
最佳答案
.NET 和 PowerShell 的当前目录概念并不总是相同的。尝试传入绝对路径。
[Diagnostics.FileVersionInfo]::GetVersionInfo('C:\Windows\System32\user32.dll')
ProductVersion FileVersion FileName
-------------- ----------- --------
6.1.7600.16385 6.1.7600.1638... C:\Windows\System32\user32.dll
此外,您可以像这样使用 Get-ChildItem 获取此信息:
Get-ChildItem C:\Windows\System32\user32.dll | fl VersionInfo
关于powershell - GetVersionInfo 和 powershell 的参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1917738/
为什么 System.Diagnostics.FileVersionInfo.GetVersionInfo() 返回意外的文件版本信息?我正在查找有关 MPIO 驱动程序的版本信息。目标操作系统是 S
为什么当加载 .NET DLL、从另一个应用程序域替换(DLL 更新为新版本),然后重新加载(使用 Assembly.LoadFrom)版本信息仍然反射(reflect)旧版本? assembly.G
我正在尝试使用 powershell 获取文件的文件版本。如果我右键单击该文件并查看版本,它会显示一个值。这是我正在尝试的方式: $path = "MSDE2000A"; $info = [Syste
我有一个在 c# 中执行的程序,有时会在运行时通过将 exe 交换为新程序来更新。我希望程序定期检查它是否已更新,如果是,则重新启动。我使用以下函数来执行此操作。 public static
我在使用 FileVersionInfo.GetVersionInfo() 时遇到了一些严重的问题,希望有人能提供帮助。 问题的基本原理是我正在遍历一个文件夹中的所有文件,每个文件都调用 GetVer
在 Silverlight 3.0 应用程序中,我想使用 AssemblyFileVersion显示应用程序的版本信息。这与 AssemblyVersion 不一样并且通常使用以下代码在 .NET 应
我是一名优秀的程序员,十分优秀!