JavascriptProva

domenica 22 luglio 2018

Ripasso di OpenFileDialog

Public Class Form1
    Dim stringa As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OpenFileDialog1.Filter = "Files HTML|*.html"
        OpenFileDialog1.FileName = ""
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            TextBox1.Text = OpenFileDialog1.FileName
            Dim stringa As String = OpenFileDialog1.FileName
            TextBox1.Text = splitPath(stringa)
            TextBox2.Text = splitFileName(stringa)
        End If
    End Sub

    Private Function splitFileName(s As String) As String
        Return s.Substring(s.LastIndexOf("\") + 1, s.Length - 1 - s.LastIndexOf("\"))
    End Function

    Private Function splitPath(s As String) As String
        Return s.Substring(0, s.LastIndexOf("\") + 1)
    End Function
End Class

Nessun commento:

Posta un commento