Hi. I am working on this ftp client and i want a column of the listview to show the date modified. I've got the code but here's the problem:

Private Sub RefreshList()
        FTPDownload.Hostname = LoginMenu.TextBox3.Text.Trim
        FTPDownload.Username = LoginMenu.TextBox1.Text
        FTPDownload.Password = LoginMenu.TextBox2.Text
        ListView1.Items.Clear()
        Try
            For Each File In FTPDownload.ListDirectory
                Dim ext As String = IO.Path.GetExtension(File)
                Dim ftp1 As Net.FtpWebRequest = Net.FtpWebRequest.Create(LoginMenu.TextBox3.Text & ToolStripStatusLabel2.Text & ToolStripStatusLabel5.Text)
                ftp1.Credentials = New NetworkCredential(LoginMenu.TextBox1.Text, LoginMenu.TextBox2.Text)
                ftp1.Method = Net.WebRequestMethods.Ftp.GetDateTimestamp
                Dim dte As DateTime
                Using response1 = CType(ftp1.GetResponse(), Net.FtpWebResponse)
                    dte = response1.LastModified
                    ListView1.Items.Add(New ListViewItem({File, ext, dte}))
                    ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
                End Using

            Next
        Catch ex As Exception
        End Try
    End Sub

I made another sub and that goes into listview click. Each time i click an item in the listview it shows the date but when the form loads the RefreshList() sub nothing happens. It doesn't show the modified dates...

Can someone help me please :)

Make the dte variable a String and convert the LastModified time to a String

So;

Dim dte as String
Using response1 = CType(ftp1.GetResponse(), Net.FtpWebResponse)
    dte = response1.LastModified.ToString("dd/MM/yyyy")
    ListView1.Items.Add(New ListViewItem({File, ext, dte}))
    ...
End Using

Try this:

Dim item1 As New ListViewItem(File)
item1.SubItems.Add(ext)
item1.SubItems.Add(dte)
ListView1.Items.Add(item1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.