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

Hi Chandra,

 

I am trying to create a text file which gets all part names in an assembly written, however I am struggling to

work out how to combine both write & read of my text file lines and only add the next part name if it doesn't already exist in previous lines.

 

Here is a basic example where I can check if the name exists - but I am unsure how to then activate the append function with it (you'll see it commented out below) so I can then add the name if its unique:

 

oFile = "C:\Temp\Names.txt"
oRead = System.IO.File.OpenText(oFile)
Dim sLine As String = ""

Do
	sLine2 = ThisDoc.FileName(False)
    sLine = oRead.ReadLine()
    If Not sLine Is Nothing Then
       If sLine <> sLine2 Then
		   
'		   oAppend = IO.File.AppendText("C:\TEMP2\Test_File.txt")
'		   oAppend.WriteLine(ThisDoc.FileName(False))
'           oAppend.Flush()
'		   oAppend.Close()

		   MsgBox(sLine2)
	   End If
    End If
Loop Until sLine Is Nothing
oRead.Close()
ThisDoc.Launch(oFile)

 Any help would be appreciated. Thanks @chandra.shekar.g