0

これが私の作業コードです:

Dim commands() =
        {
            "stmotd -a {0}",
            "stmotd -b 15 {0}"
        }


    Dim objLines = File.ReadAllLines("C:\temp\sObj.txt")
    'Dim getcount = objLines.Length

    Using SW As New IO.StreamWriter("c:\temp\MPadd.txt", True)
        For Each line In objLines
            For Each cmd In commands
                SW.WriteLine(String.Format(cmd, line))

            Next
        Next
    End Using

ここで、sObj.txt ファイルに次のエントリが含まれていると「言う」

WINMAC
WINPPC
WINVPN

上記のコードで得られる出力は次のとおりです。

stmotd -a WINMAC
stmotd -b 15 WINMAC
stmotd -a WINPPC
stmotd -b 15 WINPPC
stmotd -a WINVPN
stmotd -b 15 WINVPN

しかし、私は次のように出力したい:

stmotd -a WINMAC WINPPC WINVPN
stmotd -b 15 WINMAC WINPPC WINVPN

とても簡単なはずですが、ここで助けが必要です。ありがとう !

4

1 に答える 1

2

試してください:(今はコードをテストできません-頭からです)

 Dim commands() =
    {
        "stmotd -a ",
        "stmotd -b 15 "
    }

Dim objLines = File.ReadAllLines("C:\temp\sObj.txt")

 Using SW As New IO.StreamWriter("c:\temp\MPadd.txt", True)
    For Each cmd In commands
        dim com as String=cmd
        For Each line In objLines
            com=com & " " & line
        Next
      SW.WriteLine(com)
    Next
End Using
于 2013-05-21T11:45:03.703 に答える