All files in a folder to ListView?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
Hello guys,
I just need little help, i just want a code that can make this:
If i have a listview, and it has 2 columns, first is called "File Name" and second called "path" i want it to put all the files from folder, "C:/Files/" so each files in that directory will be added to the listview, ? how can i do this? i mean what is the code?
Thanks hehaho;
I just need little help, i just want a code that can make this:
If i have a listview, and it has 2 columns, first is called "File Name" and second called "path" i want it to put all the files from folder, "C:/Files/" so each files in that directory will be added to the listview, ? how can i do this? i mean what is the code?
Thanks hehaho;
You could do this
Code: Select all
Dim path = "C:/Files/"
Dim lpath = path.LastIndexOf("\")
Dim fpath = path.Replace(lpath, "")
For Each file As String In System.IO.Directory.GetFiles(path)
Dim item As New ListViewItem(System.IO.Path.GetFileName(file))
ListView1.Items.Add(item)
item.SubItems.Add(fpath)
Next
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023