vb.net - adding vertical text each item in text file writeline with some text -
i populating listbox text & saving output textfile (sobj.txt)
'saving items of lb1 in file under c:\temp dim integer w = new io.streamwriter("c:\temp\sobj.txt") = 0 lb1.items.count - 1 w.writeline(lb1.items.item(i)) next w.close()
this text file contains 3 (for example) entries, let's abc in 1st line, def in 2nd line & ghi in 3rd line.
now want append text file (mpadd.txt) using sobj.txt entries such following:
'appending listbox items file mpadd.txt using sw new io.streamwriter("c:\temp\mpadd.txt", true) sw.writeline("some text" & abc & "some text") sw.writeline("some text" & def & "some text") sw.writeline("some text" & ghi & "some text") end using
please in getting correctly. thanks.
just read lines first file (just 3 lines not problem) , loop on these lines adding prefix , postfix text like
edit following last example
dim commands() = { "cdhdef -t ftpv2 -c r -f {0} -x ", "cdhdsdef -v cpusrg {0} ", "cacls k:\aes\data\cdh\ftp\{0}\archive /e /g ossuser:c" } dim counter integer = 0 dim objlines = file.readalllines("c:\temp\sobj.txt") using sw new io.streamwriter("c:\temp\mpadd.txt", true) ' loop number of strings in commands (max 3 now) x = 0 commands.length - 1 line = objelines(x).trim ' check prevent empty lines used output if line <> string.empty sw.writeline(string.format(commands(counter), line)) counter += 1 end if next end using
this example use composite formatting define format string , progressive placeholder want insert value.
of course work if have 3 lines in input file
Comments
Post a Comment