General_GSpot
asked on
Missing dates on Listview
here is my code:
Don't know what I'm missing, but I can only see the date on the first file in my listview, i'm certain it's a + 1 somewhere, just couldn't see it.
Anyone help?
Private Sub treeview1_afterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim subitemindex As Integer
Dim datemod As String
If TreeView1.SelectedNode.Nodes.Count = 1 AndAlso TreeView1.SelectedNode.Nodes(0).Text = "Loading..." Then
TreeView1.SelectedNode.Nodes.Clear()
AddAllFolders(TreeView1.SelectedNode, CStr(TreeView1.SelectedNode.Tag))
End If
ListView1.Items.Clear()
Dim folder As String = CStr(TreeView1.SelectedNode.Tag)
If Not folder Is Nothing AndAlso IO.Directory.Exists(folder) Then
Try
For Each File As String In IO.Directory.GetFiles(folder)
datemod = IO.File.GetLastWriteTime(File).ToString()
ListView1.Items.Add(File.Substring(File.LastIndexOf("\"c) + 1), File.ToString())
ListView1.Items(subitemindex).SubItems.Add(datemod.ToString())
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
Don't know what I'm missing, but I can only see the date on the first file in my listview, i'm certain it's a + 1 somewhere, just couldn't see it.
Anyone help?
Are you sure that there are different file-dates in your directory ?
ASKER
I know right, well, it happens now on 2 different directories. I may not have a large enough sample size, but each of the two directories have about 13 messages in them, yet only the first in each shows a date.
So are you saying the code is correct?
So are you saying the code is correct?
Does it work if you use GetCreationTime function?
ASKER
@CodeCruiser,
Honestly, this is my third week coding, trying to move from just PC support to a bit more and haven't had time to study/practice that much. Having trouble getting functions in... can you provide an example?
Thanks.
Honestly, this is my third week coding, trying to move from just PC support to a bit more and haven't had time to study/practice that much. Having trouble getting functions in... can you provide an example?
Thanks.
Just change this bit
datemod = IO.File.GetLastWriteTime(F ile).ToStr ing()
to
datemod = IO.File.GetCreationTime(Fi le).ToStri ng()
datemod = IO.File.GetLastWriteTime(F
to
datemod = IO.File.GetCreationTime(Fi
ASKER
Same deal, I'll just try to get a larger sample size.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@ark, your rank is true.
Glad I could help