Writing a string to a new .csv in VB.net
<p>I am trying to write a string to a .csv file, but unable to get it to display.
I have managed to do it in VBA, but when writing in VB.net it's not working.</p>

<p>I first create the file and set the headers for each column. After this I am getting information on each required attribute and writing it to a string s. 
All i want to do now is write the string to the .csv file so that each attribute is in the right column under the right header. 
Each time the string s simply needs to be on a new row.</p>

<p>This is what I have so far (I have cut out some bits of code so some syntax may look incorrect). What am i doing wrong or missing?</p>

<pre><code>    Sub Main()
     Dim sOutput As String
    ' Create a header for the output file
    sOutput = ("Level,Occurrence Name,Reference Name,Object type, Visibility, Path" &amp; vbLf)

            If Occs.Count &gt; 0 Then
        For i = 1 To Occs.Count
            iLevel = 0
            curOcc = Occs.Item(i)
            GetOccurrenceData(curOcc, sOutput, oSel, False, iLevel)
        Next
    End If

    ' Write the output string to a file
    Dim sPath As String
    Dim bWrite As Boolean
    sPath = ("C:\temp\data3.csv")
    bWrite = WriteFile(sPath, sOutput)
End Sub


Sub GetOccurrenceData(curOcc As VPMOccurrence, s As String, sel As Selection, ByVal bParentHidden As Boolean, ByVal iParentLevel As Integer)
'CODE TO GET DATA REMOVED AS IRRELEVANT 

     ' Append the output string with the data for the current occurrence.
    s = (s &amp; curLevel &amp; "," &amp; sName &amp; "," &amp; sRefName &amp; "," &amp; sType &amp; "," &amp; sVisibility &amp; vbLf)

    ' Repeat this data gathering procedure on any children the current occurrence may have.
    Occs = curOcc.Occurrences
    If Occs.Count &gt; 0 Then
        For i = 1 To Occs.Count
            GetOccurrenceData(Occs.Item(i), s, sel, bChildrenInheritNoShow, curLevel)
        Next
    End If
</code></pre>