Today, I will teach you how to create a recent files to be displayed in the ListView in VB.NET.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add one listview named listViewrecentfiles with three columns namely Item name, Date Created, and Name of the file, and one button also named button1checkrecent. Insert ImageList with some images that you wanted to use. You must design your interface like this:
3. Now, we will do the coding.
We will import the following libraries below to access the component model and diagnostics.
- Imports System.IO, System.Diagnostics, System.ComponentModel
Then we will find the recent folder path. Use the code below:
- Dim RecentFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Recent)
For our button, put this code below:
- Private Sub button1checkrecent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1checkrecent.Click
- Dim lstitem As New ListViewItem()
- For Each RecentFile1 In Directory.GetFiles(RecentFolderPath)
- imageList1.Images.Add(RecentFile1, Icon.ExtractAssociatedIcon(RecentFile1))
- 'add file and its icon
- lstitem = listViewrecentfiles.Items.Add(RecentFile1, RecentFile1)
- 'add created date
- lstitem.SubItems.Add(New FileInfo(RecentFile1).CreationTime.ToLongDateString())
- 'add only name without extension
- End Sub
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Subscribe at my YouTube Channel at: Ser Bermz
Visit my website at: www.campcodes.com
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.