Retrieve list by timestamp

May 16, 2010 at 10:46:25
Specs: Windows 7
Ok, so I am creating a proof of function. Right now just have a simple setup in a close to blank form. Listbox shows files in a folder when the button is hit:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' make a reference to a directory
Dim localDir As New IO.DirectoryInfo("c:\test")
Dim getList As IO.FileInfo() = localDir.GetFiles()
Dim dra As IO.FileInfo

'list the names of all files in the specified directory
For Each dra In getList
ListBox1.Items.Add(dra)
Next
End Sub

Now, what I would like to do, is have it return only the files in that folder modified between 10:00 and 10:15 today. Any thoughts?


See More: Retrieve list by timestamp

Report •


#1
May 16, 2010 at 19:14:20
I'm not familiar with the objects you're using (very naieve when
it comes to vbscript and Oop.)
this works with standard filesystemobject, maybe you can adapt it:
set d=fso.getfolder(".\")
for each fil in d.files
f = fso.GetFile(fil)
dat=fil.datelastmodified
test=formatdatetime("n",dat,4)
test2=datediff("n","10:00",test)
if test2>0 and test2<31
listbox1.items.add(fil)
end if
next

Report •

#2
May 16, 2010 at 20:01:41
Good idea, but still running across a couple of things. An easy way to run a quick test for what I am doing, is have a simple windows form, one itemlist box and a button. Code that I currently have for the button as follows:

' make a reference to a directory
Dim localDir As New IO.DirectoryInfo("c:\test")
Dim getList As IO.FileInfo() = localDir.GetFiles()
Dim dra As IO.FileInfo

'list the names of all files in the specified directory
For Each dra In getList
ListBox1.Items.Add(dra)
Next


Report •

#3
May 17, 2010 at 09:25:13
I suggest you use GetFileSystemInfos() instead of GetFiles().

Report •

Related Solutions

#4
May 17, 2010 at 10:58:28
I tried that, but getting exceptions.

Lets drill down a little more into the functionality. On the form now, are buttons down the left showing time in 30 minute incraments. (10:00. 10:30, etc). So, when button 10:00 is pressed, it returns the list of files that were modified between 10:00:00 and 10:29:59

I thought it would be pretty straight forward, but banging my head against the wall. The final product, I want to press the button for 10:00 and have it display the photos during that time on the right hand side.


Report •

#5
May 18, 2010 at 06:24:42
bsod: I tried that, but getting exceptions
Such as . . . ?

Report •


Ask Question