Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
RoyWickrama_RWEI
710 Views, 7 Replies

Write to Notepad keeps growing every time the rule is run

As a part of my rule, I need to write data into a text file. I noticed that, it keeps growing instead of creating a new text file.

Could someone help, please!

Thanks.

Public Class forBomStructure
	Shared oTextSave As String = "C:\Users\Public\Documents\iLogicBuffer.txt"
			
	Sub Main()
'	create_txt(oWritex)
		Dim oDoc As Document = ThisApplication.ActiveDocument
		Dim oModelDoc As Document
		Dim oStr As String = ""
		Dim iL_Name as String = "0023A Full File Names of Occurrences"
			oWrite_Sub(oWrite, "FILE REFERENCE TREE RAN FROM: " & oDoc.FullFileName)			
			oWrite_Sub(oWrite, "RULE: " & iL_Name)	
			oWrite_Sub(oWrite, "-----------------------------")
'			Process.Start ("Notepad.exe", oTextSave)
'			Exit Sub
		
			For Each oModelDoc In oDoc.AllReferencedDocuments
''				RecurReferencing(oModelDoc, oStr, 0)
'				MessageBox.Show("oModelDoc.Name: " & oModelDoc.FullFileName, "Title")
'				oFFN_Document = oModelDoc.FullFileName
'				oWrite_Sub(oWrite, oFFN_Document)
			Next
			
		Process.Start ("Notepad.exe", oTextSave)
	
	End Sub
	
	Sub oWrite_Sub(oWrite As System.IO.StreamWriter, oStr_to_Write As String)

		oWrite = System.IO.File.AppendText(oTextSave)
		oWrite.WriteLine(oStr_to_Write)	
		oWrite.Flush()
		oWrite.Close

	If My_Expression Then
		'---------------
		End If
	End Sub
		
		
End Class