Hi. First Post...
Just need some help with this program I'm doing..
I've been programming a FTP Client and i've got the base done but i just have one problem...I've added a listview with 3 columns. 1st column is File Name, 2nd column is File type and the 3rd column is File Modified. The problem is that I've managed to get the file type and file name both come under their relevent column but i just can't get the date modified to work the same. Can some please help me on this. Been working for HOURS.... and still nothing
My Code for that particular page is :
Imports System.Net
Imports System.IO
Public Class MainMenu
Private Sub MainMenu_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadFiles()
Timer1.Start()
End Sub
Public Sub TimeDate()
Try
Dim ftp1 As Net.FtpWebRequest = Net.FtpWebRequest.Create(Login.TextBox3.Text & ListView1.SelectedItems(0).Text)
ftp1.Credentials = New NetworkCredential(Login.TextBox1.Text, Login.TextBox2.Text)
ftp1.Method = Net.WebRequestMethods.Ftp.GetDateTimestamp
Dim dte As DateTime
Using response1 = CType(ftp1.GetResponse(), Net.FtpWebResponse)
dte = response1.LastModified
Dim listviewitem As ListViewItem = New ListViewItem
End Using
Catch ex As Exception
End Try
End Sub
Public Sub LoadFiles()
Dim ftp As FtpWebRequest = DirectCast(WebRequest.Create(Login.TextBox3.Text), FtpWebRequest)
ftp.Method = WebRequestMethods.Ftp.ListDirectory
Dim ftpFiles As New Collection()
ftp.Credentials = New NetworkCredential(Login.TextBox1.Text, Login.TextBox2.Text)
Dim Response As FtpWebResponse = ftp.GetResponse()
Dim responseStream As Stream = Response.GetResponseStream()
Dim reader = New StreamReader(responseStream)
While Not (reader.EndOfStream)
ftpFiles.Add(reader.ReadLine)
End While
For Each file In ftpFiles
Dim ext As String = IO.Path.GetExtension(file)
Dim listviewitem As ListViewItem = New ListViewItem
listviewitem = ListView1.Items.Add(file)
listviewitem.SubItems.Add(ext)
Next
reader.Close()
responseStream.Close()
Response.Close()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
For Each lvi In ListView1.Items
Dim masterItem = From i In ListView1.Items.OfType(Of ListViewItem)()
Where i.Text = "."
Dim masterItem1 = From i In ListView1.Items.OfType(Of ListViewItem)()
Where i.Text = ".."
If masterItem.Any Then
ListView1.Items.Remove(masterItem.First)
ListView1.Items.Remove(masterItem1.First)
End If
Next
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
TimeDate()
End Sub
End Class
Thanks.
Ahmed.C