?
Solved

Missing dates on Listview

Posted on 2011-05-05
9
Medium Priority
?
254 Views
Last Modified: 2012-05-11
here is my code:
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

Open in new window


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?
0
Comment
Question by:General_GSpot
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 35697647
Are you sure that there are different file-dates in your directory ?
0
 
LVL 1

Author Comment

by:General_GSpot
ID: 35697679
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?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35697785
Does it work if you use GetCreationTime function?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:General_GSpot
ID: 35697811
@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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35698449
Just change this bit

datemod = IO.File.GetLastWriteTime(File).ToString()


to

datemod = IO.File.GetCreationTime(File).ToString()
0
 
LVL 1

Author Comment

by:General_GSpot
ID: 35698512
Same deal, I'll just try to get a larger sample size.

0
 
LVL 28

Accepted Solution

by:
Ark earned 1000 total points
ID: 35704421
Since you don't increase subitemindes
ListView1.Items(subitemindex).SubItems.Add(datemod.ToString())
means
ListView1.Items(0).SubItems.Add(datemod.ToString())

You can use
ListView1.Items.Add(File.Substring(File.LastIndexOf("\"c) + 1), File.ToString()).SubItems.Add(datemod.ToString())
0
 
LVL 1

Author Closing Comment

by:General_GSpot
ID: 35705723
@ark, your rank is true.
0
 
LVL 28

Expert Comment

by:Ark
ID: 35710593
Glad I could help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question