Member Avatar for leyla

Hi, I have been given the task of basically reading and writing to and from files. Below is the code from one sub:

      If btnSaveRecipe.Enabled = True Then
            FileName = "C:\Users\Leyla\Documents\Recipe Task\Recipe.txt"
            FileWriter = New IO.StreamWriter(FileName)
            For index = 0 To lstRecipe.Items.Count - 1 'For the number of ingredients in the listbox
                StrEntry = lstRecipe.Items(index)
                FileWriter.Write(StrEntry)
                FileWriter.Write(vbNewLine) 'Start a new line
            Next

I can't work out what i've done wrong, but when I open the file itself in the folder, it is empty. Please help :)

public sub ListFiles()
'DIR for folder
'add each file to ListBox control
For each file as string in IO.directory.getfiles(Folder Path)
Listbox.items.Add(file)
next
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.