HelpNaming a variable

Posts 1–2 of 2 · Page 1 of 1
Naming a variable
So, im trying to code this program that'll pull the pictures out of your directory yes? but theres one problem..i need to know the name of the file i want to pull, i have the folder location, but is there a way to dedicate the name of the picture without me actually knowing it? like how in permissions in minecraft where a * is everything, is there an equivalent in vb that i could use, or do i need to make a big loop to get all file names possible
Quote Originally Posted by Trojanman24 View Post
So, im trying to code this program that'll pull the pictures out of your directory yes? but theres one problem..i need to know the name of the file i want to pull, i have the folder location, but is there a way to dedicate the name of the picture without me actually knowing it? like how in permissions in minecraft where a * is everything, is there an equivalent in vb that i could use, or do i need to make a big loop to get all file names possible
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Resize the Control
        Me.Size = New Size(500, 250)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle


        'Creates a new listview with the following properties
        Dim lv As New ListView
        With lv
            .Dock = DockStyle.Fill ' -----------------------|
            .View = View.Details ' -------------------------|
            .FullRowSelect = True ' ------------------------|
            .GridLines = True ' ----------------------------|
            ' End of properties


            Me.Controls.Add(lv)


            'Creates listview columns
            Dim col1, col2 As New ColumnHeader
            col1.Text = "File Path"
            col2.Text = "File Name"
            .Columns.AddRange(New ColumnHeader() {col1, col2})
            ' and then resizing by half - 5
            For Each col As ColumnHeader In .Columns
                col.Width = (lv.Width / 2) - 5
            Next
        End With


        ' Now extracting the files
        Dim path As String = "C:\Users\Aaron\Desktop\Slides" 'File Path
        Dim dirInfo As New IO.DirectoryInfo(path)
        Dim fileInfo As IO.FileInfo() = dirInfo.GetFiles()


        'list the names of all files in the specified directory
        For Each file As IO.FileInfo In fileInfo ' Goes through each file in this directory provided by "Path"
            Dim item As New ListViewItem(file.FullName) ' [Step 1] Creates a new ListViewItem & Sets the first column (Indexed as 0) as the full file path of the file
            item.SubItems.Add(file.Name) ' [Step 2] Now, creates a sub item of the same item that was intially created of the file name
            lv.Items.Add(item) ' [Step 3] Finally, adding the item into the listview
        Next ' and will now go to the next file and complete step 1 - 3 again until there are no more files to read
    End Sub
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us