【发布时间】:2013-12-26 17:50:12
【问题描述】:
我在下面粘贴了一个文本文件转储,我只需要显示磁盘的大小,例如在 msgbox 中。在下面的这种情况下,它将显示 (500.1GB) 3 次,每个 HDD 一个尺寸。我不确定该怎么做。没有我可以划定的固定间距。我已经粘贴了下面的代码。任何帮助将不胜感激。
<DISK LIST>
Disk State Disk Type Port Type Speed Size Free CA
---- -------- -------- ---------------- ------- ------- ------- -------
0 Online Disk SATA-II/NCQ 6Gb/sec 500.1GB 492.0GB -RW
1 Online Disk SATA-II/NCQ 6GB/sec 500.1GB 492.0GB -RW
2 Online Disk SATA-II/NCQ 6GB/sec 500.1GB 492.0GB -RW
<ARRAY LIST>
...
这是我目前拥有的代码。
Const ForReading = 1
Const ForWriting = 2
Dim match, sizeCount, tempArray, foundSection
match = false
matchString = "Size"
foundSection = false
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\dump.txt", ForReading, True)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
if strLine <> "" then
tempArray = Split(strLine," ",-1,1)
match = true
End If
If InStr(strLine, matchString) = 0 Then
wscript.echo("found")
foundSection = true
End If
if (match) then
If (IsNumeric(tempArray(0))) Then
sizeCount = sizeCount + 1
disksize = disksize & Trim(tempArray(0)) & " "
End If
End if
If (tempArray(0)) = "<ARRAY" Then
foundSection = false
End If
Loop
Wscript.Echo("disk size =" & disksize)
谢谢。
【问题讨论】: