如何归档以下内容?
我希望能够遍历Collection
中PartPrograms
的{{1}},但是仍然可以像在Send()
-> {{1}中一样直接访问“变量” }
Generate()
答案 0 :(得分:0)
我找到了符合我要求的解决方案
Public Class ProgramManager
Public Programs As New List(Of PartProgram) 'Stores all partprograms
Sub Generate()
Programs.Add(New PartProgram With {
.name = "FU2PIECE.MPF",
.data = System.IO.File.ReadAllText(pathTemplate & "\FU2PIECE.MPF", System.Text.Encoding.UTF8) _
.Replace("$DATE$", DateTime.Now.ToString("dd/MM/yy HH:mm:ss")) _
.Replace("$JOBINFO$", sji.ShortJobInfo) _
.Replace("$VERSION$", My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor)
})
[...]
End Sub
Sub Send()
For Each prog In Me.Programs
System.IO.File.WriteAllText(root & "\" & prog.name, prog.data)
Next
End Sub