Powershell将字符串转换为字节大小

问题描述 投票:0回答:1

如何将整数或字符串变量更改为如下所示的字节大小?

$examineLine = 35
$copySizeLimit = $examineLine+MB
$copySizeLimit

对于上述示例,将数字35转换为35MB输出应为36700160但是错误:

“您必须在'+'运算符之后提供一个值表达式。”

string powershell type-conversion data-conversion
1个回答
0
投票

实际上是“ *”符号,而不是“ +”:

$size = 10
$sizeinmb = $size * 1MB
© www.soinside.com 2019 - 2024. All rights reserved.