Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Open or Find file by FileDateTime


Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2005, 12:41 PM
rcorrea's Avatar
rcorrea rcorrea is offline
Centurion
 
Join Date: Aug 2003
Posts: 188
Default Open or Find file by FileDateTime


I have a string that is equal to the date/time a file was modified.

How would I go about finding a file by name, with this string?
__________________
Love thy neighbor, or he'll shoot you.
Reply With Quote
  #2  
Old 11-17-2005, 12:51 PM
vbtricks's Avatar
vbtricks vbtricks is offline
Junior Contributor
 
Join Date: Jul 2005
Location: Germany
Posts: 289
Default

Well,

I think there's no function that allows searching files by last-modified-date. So you'll have to do a dir-function for *.* and then check last-modified-date for the correct date. Do you know how to write such a function. FindFirstFile-api could speed things up.

Stefan
__________________
VBTricks.de.vu the free source for all Visual Basic issues in English. Free controls, classes and whole projects available. Deals also with (Free) Pascal and Gambas.
Reply With Quote
  #3  
Old 11-17-2005, 02:06 PM
rcorrea's Avatar
rcorrea rcorrea is offline
Centurion
 
Join Date: Aug 2003
Posts: 188
Default hi

Quote:
Originally Posted by vbtricks
Well,

I think there's no function that allows searching files by last-modified-date. So you'll have to do a dir-function for *.* and then check last-modified-date for the correct date. Do you know how to write such a function. FindFirstFile-api could speed things up.

Stefan

Hi thanks for your response. Darn no function, oh well.

What I'm working on now, is I have an array with all the file names that I will need to search. I'm going to loop through the array checking dates based on that string somehow.
__________________
Love thy neighbor, or he'll shoot you.
Reply With Quote
  #4  
Old 11-17-2005, 02:53 PM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 601
Default

Quote:
Originally Posted by rcorrea
Hi thanks for your response. Darn no function, oh well.

What I'm working on now, is I have an array with all the file names that I will need to search. I'm going to loop through the array checking dates based on that string somehow.
iam a noob... but one could use the file system object to search for the modifi date?
Code:
Private Sub Form_Load() Dim Fso As New FileSystemObject Dim Drive As Drive Dim File As File Dim SubFolder As Folder For Each Drive In Fso.Drives If Drive.IsReady Then For Each File In Drive.RootFolder.Files Debug.Print File.DateLastModified Next For Each SubFolder In Drive.RootFolder.SubFolders SubDirectorys SubFolder Next End If Next End Sub Private Function SubDirectorys(SubDirectory As Folder) Dim File As File Dim Folder As Folder If SubDirectory.SubFolders.Count <> 0 Then For Each Folder In SubDirectory.SubFolders SubDirectorys Folder Next Else For Each File In SubDirectory.Files Debug.Print File.DateLastModified Next End If End Function
aldo this might take a while and iam not sure it this the best way of going around this problem
Reply With Quote
  #5  
Old 11-17-2005, 05:46 PM
Diurnal Diurnal is offline
Enthusiast

Retired Leader
* Expert *
 
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
Default

Check out the FileDateTime() function. Look in your MSDN help file. You could loop through your file names and use it to compare to the time and date you need.
Reply With Quote
  #6  
Old 11-17-2005, 05:57 PM
rcorrea's Avatar
rcorrea rcorrea is offline
Centurion
 
Join Date: Aug 2003
Posts: 188
Default

Quote:
Originally Posted by Diurnal
Check out the FileDateTime() function. Look in your MSDN help file. You could loop through your file names and use it to compare to the time and date you need.
Yep filedatetime is what I am using. Works fine, and is easy.

Here's what I came up, thought I would share my loop. strlogarray() is a list of the log files I made in another form.

Code:
ff = FreeFile() strfiles = ListView1.SelectedItem For i = 0 To UBound(strLogarray) If FileDateTime("\\ppfwav\logs\" & strLogarray(i)) = strfiles Then strfiles = Dir$("\\ppfwav\logs\" & strLogarray(i)) Open "\\ppfwav\logs\" & strfiles For Input As ff Do While Not EOF(ff) Line Input #ff, strTextfile textbox.Rtfbox.SelText = strTextfile & vbCrLf Loop End If Next i
__________________
Love thy neighbor, or he'll shoot you.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->