开发者

How to write content in a text file at the end of each line

I am having one text file which contain following kind of data.

"3P","Smith","Richard","3 Point Promotions","3P","richs51@gmail.com","IDA","Yes",,,,0,4,5,83.33,10,
"A1","Ernest",开发者_开发技巧"Amy","TAKE 1 Promotional Products","LCOOK","lcpromos@adelphia.net","IDA","Yes",,,,0,6,7,,0,
"A2","Derek","Eaton","Advertising Edge Promotions","AE","dereke@adedgepro.com","IDA","Yes",,,,0,8,8,,10,
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","wabercro@bellsouth.net","IDA","Yes",,,,0,9,9,,10,
"AAP","Halberstam","Mendy","All About Promotions","AAP","mendyaap@yahoo.com","IDA","Yes",,,,0,10,10,,12,

Each of them are separate line.Now i want add another column in each like this

"3P","Smith","Richard","3 Point Promotions","3P","richs51@gmail.com","IDA","Yes",,,,0,4,5,83.33,10,**96**
"A1","Ernest","Amy","TAKE 1 Promotional Products","LCOOK","lcpromos@adelphia.net","IDA","Yes",,,,0,6,7,,0,**97**
"A2","Derek","Eaton","Advertising Edge Promotions","AE","dereke@adedgepro.com","IDA","Yes",,,,0,8,8,,10,**98**
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","wabercro@bellsouth.net","IDA","Yes",,,,0,9,9,,10,**99**
"AAP","Halberstam","Mendy","All About Promotions","AAP","mendyaap@yahoo.com","IDA","Yes",,,,0,10,10,,12,**100**

How i read content in line by line.And also how to write another value in same text file at each line.Please send solution for this problem.I am waiting for your reply.Thanks for reply. -Saravanan


Maybe something like this:

Dim lines() As String
Using reader As New IO.StreamReader(filePath)
     Dim sep() As String = {vbNewLine}
     lines = reader.ReadToEnd().Split(sep, StringSplitOptions.RemoveEmptyEntries)
End Using
Dim Index as Int32 = 1
Using writer As New IO.StreamWriter(filePath, False)
     For Each line As String In lines
          writer.WriteLine(line & "," & Index.ToString())
     Next
End Using
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜