Capture only the second part of the string

0

I have the following code to perform method Split in a path:

Dim ItemsCopy As Integer = 0


    Dim Caminho As String = ContarItems(I)
    Dim SplitCam As String() = Regex.Split(Caminho.ToString, "=")

    For Each S As String In SplitCam

        Vizualizador.ListBox1.Items.Add(S)
    Next

Where has the ContarItems(I) % is a array that put on just to save the URL, but the following have a URL

Exemplo: Victor\junior\Documentos\=Pasta\Teste\arquivo.teste

When using the method it cuts straight-laced and adds the listbox , but I wanted it just put the second part of the event Pasta\Teste\arquivo.teste he puts the first and second, and do not want this first part.

    
asked by anonymous 14.11.2014 / 18:39

3 answers

1

It seems simple to me, but it may be that the question is not well explained. Confirm me to try to adjust or remove the answer.

Dim ItemsCopy As Integer = 0
Dim Caminho As String = ContarItems(I)
Dim SplitCam As String() = Regex.Split(Caminho.ToString, "=")
//tem que pegar um elemento específico (índice 1 é o segundo) e não varrer todo o array
Vizualizador.ListBox1.Items.Add(S(1))

I placed GitHub for future reference a>.

    
14.11.2014 / 18:46
0

Consider changing your code to something that contains

Dim documentos As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Dim meuArquivoDiretorio As String = "Pasta\Teste\arquivo.teste"

Dim fi = New System.IO.FileInfo(System.IO.Path.Combine(documentos, meuArquivoDiretorio))
fi.Directory.Create()

Dim FullFileName As String = fi.FullName
    
14.11.2014 / 18:46
0

No! the function normally runs without any problem it goes exactly like this in the code, above this there is one that simply checks each line of the listbox stores it in the array and passes to another function that I posted, but n wanted that first part of the string only the second part as demonstrated in the above code.

Dim ContarItems(10) As String
    Dim I As Integer = 0
    Public Sub ExcluirArquivosDesatualizados()
        Dim contar As Integer = Vizualizador.LSTCaminho.Items.Count - 1

        For I = 0 To Vizualizador.LSTCaminho.Items.Count - 1
            Vizualizador.LSTCaminho.SelectedIndex = I

            ContarItems(I) = Vizualizador.LSTCaminho.SelectedItem.ToString
            teste()
        Next


        I = Vizualizador.LSTCaminho.Items.Count - 1
        MsgBox("0 = " & ContarItems(0).ToString & vbNewLine & _
               "1 = " & ContarItems(1))
    End Sub
    
14.11.2014 / 18:54