Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

Get the names of files in a folder BY last modified date

$
0
0
Hello all;

I am new to vb2010 express and was wondering if I may get some help.

I am attempting to obtain the names of the files in a folder (without their extensions) by the last date they are modified.
I only need to get the most recent 6 of them. I am then ading them to the ToolStripTextBox menu as a quick link to open them.

This is what I have thus far:

Code:

Public Sub Get_Recent_File()
        Dim x As Integer = 1
        Dim infoReader As System.IO.FileInfo

        Do
            For Each fileFound As String In My.Computer.FileSystem.GetFiles(Recipes_Path)
                infoReader = My.Computer.FileSystem.GetFileInfo(fileFound)

                If FormatDateTime(Now, DateFormat.ShortDate) >= FormatDateTime(infoReader.LastWriteTime, DateFormat.ShortDate) Then
                    RF(x) = System.IO.Path.GetFileNameWithoutExtension(fileFound)

                End If

            Next

            x = x + 1

        Loop Until x = NumRecentFavorites

    End Sub

This part returns 6 of the same file name. What am I doing wrong? Anyone care to help?

I appreciate all help.

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>