.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Whay do i get only the last pattern written on the file?
 

Whay do i get only the last pattern written on the file?

Hi all


The code below writes only the ladst pattern on the txt file. Do you perhaps have any idea why?

Dim pattern As String = "<BOOKMARK[^>]*>"
Dim m As Match = Regex.Match(TextBox1.Text, pattern)

saveFileDialog3.Filter = "Text files (*.txt) |*.txt"
Dim EntireFile As String
Dim oWrite As System.IO.StreamWriter
oWrite = IO.File.CreateText("C:\tag_temp.txt")

While (m.Success)
m = m.NextMatch()
Dim bmStr As String = m.Value
oWrite.Write(bmStr)
oWrite.Close()
End While
Pilot_
If you want to write more than one item to the file you can't Close the writer on the first loop iteration.

Mattias, C# MVP
  • Marked As Answer byPilot_ Wednesday, September 03, 2008 8:46 AM
  •  
Mattias Sjögren
If you want to write more than one item to the file you can't Close the writer on the first loop iteration.

Mattias, C# MVP
  • Marked As Answer byPilot_ Wednesday, September 03, 2008 8:46 AM
  •  
Mattias Sjögren

You can use google to search for other answers

Custom Search

More Threads

• Help with creating of delegate using DynamicMethod and ILGenerator
• RSACryptoServiceProvider and CmsSigner, constructed with CspParameters - disable smartcard dialog pin
• CodeDomProvider Parse Method
• xml serialize a dictionary with a custom class
• JMX MBean Microsoft Equivilent
• which framework is being used on an x64 box?
• Set AssemblyLocation
• CodeDOM - Problem with CodeMemberField
• Hex to Dec to Ascii multi conversion
• wincv - Get application error on startup