Recent Files - Display in VB.NET

Submitted by: 
Visitors have accessed this post 194 times.

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:

output

3. Now, we will do the coding.

We will import the following libraries below to access the component model and diagnostics.

  1. Imports System.IO, System.Diagnostics, System.ComponentModel

Then we will find the recent folder path. Use the code below:

  1. Dim RecentFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Recent)

For our button, put this code below:

  1. Private Sub button1checkrecent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1checkrecent.Click
  2. listViewrecentfiles.Items.Clear()
  3. Dim lstitem As New ListViewItem()
  4. imageList1.Images.Clear()
  5. For Each RecentFile1 In Directory.GetFiles(RecentFolderPath)
  6. imageList1.Images.Add(RecentFile1, Icon.ExtractAssociatedIcon(RecentFile1))
  7. 'add file and its icon
  8. lstitem = listViewrecentfiles.Items.Add(RecentFile1, RecentFile1)
  9. 'add created date
  10. lstitem.SubItems.Add(New FileInfo(RecentFile1).CreationTime.ToLongDateString())
  11. 'add only name without extension
  12. lstitem.SubItems.Add(Path.GetFileNameWithoutExtension(RecentFile1))
  13. Next
  14. End Sub

Output:

output

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]

Add and Follow me on Facebook: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.