[HELP] how to write data from Listbox1 and Listbox2 RRS feed

  • Question

  • hi guys..

    i have 2 Listbox

    Listbox1 = have file names

    Listbox2 = have path names of files

    i need use IO.File.WriteAllText to make TXT file look like this proof

    name of this txt files is from listbox1

    after that this files txt have data from listbox1 and listbox2

    please help

    Friday, July 14, 2017 7:07 AM

All replies

  • after that this files txt have data from listbox1 and listbox2

    You need to make two adjustments to assist in getting your queries answered.

    One is to acknowledge the assistance provided for earlier requests by marking those responses that were useful as answers.

    The other is to remove the [HELP] from your title.

    In addition, for this particular thread, you should indicate what the actual problem is, instead of simply stating what you want to do.

    Friday, July 14, 2017 8:28 AM
  • Hi KORG.Pa3x,

    According to your description, you want to create txt file that contains file name and path, you just Traversal ListBox2 items and split file name and path. Please refer to the code below.

     For i As Integer = 0 To ListBox2.Items.Count - 1
                Dim str As String = ListBox2.Items(i)
                Dim arraylist() As String = Split(str, "\")
                Dim value As Integer = arraylist.Length - 1
                Dim path As String = "D:\TestFile\" + arraylist(value)
                If File.Exists(path) = False Then
                    Dim createText As String = "Name=" + arraylist(value) + Environment.NewLine + "Path=" + ListBox2.Items(i)
                    File.WriteAllText(path, createText)
                End If

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Proposed as answer by Stanly Fan Wednesday, July 19, 2017 7:42 AM
    Tuesday, July 18, 2017 7:59 AM