473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

lookup text file creation date

157 100+
Hello!

I am designing an import module in my access database for text files

it looks like this
Expand|Select|Wrap|Line Numbers
  1. Dim GammeltNavn As String
  2. Dim NyttNavn As String
  3. Dim MaskinNavn As String
  4. Dim fsoFileSearch As FileSearch
  5. Set fsoFileSearch = Application.FileSearch
  6. With fsoFileSearch
  7.  
  8. 'Dim NettVerkssøk As New ADODB.Recordset
  9.    ' NettVerkssøk.Open "SELECT * from [tbl atfmaskiner]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  10.    ' Do Until NettVerkssøk.EOF
  11. .NewSearch
  12. '.LookIn = "\\" & NettVerkssøk!Maskinnavn & "\ATF" & Right(NettVerkssøk!Maskinnavn, 1)
  13. .LookIn = "C:\ATF4"
  14. .FileType = msoFileTypeAllFiles
  15. .SearchSubFolders = False
  16. MaskinNavn = "Gemba Maskin 4"
  17.  
  18.  
  19. Dim RSTFRA As New ADODB.Recordset
  20. Dim RSTTIL As New ADODB.Recordset
  21. Dim RSTTIL2 As New ADODB.Recordset
  22.  
  23. If .Execute(msoSortByLastModified) > 0 Then
  24.     'MsgBox .FoundFiles.Count & " fil(er) funnet"
  25.  
  26.     For i = 1 To .FoundFiles.Count
  27.         MsgBox .PropertyTests
  28.         If Right(.FoundFiles(i), 2) = "F6" Then
  29.         GammeltNavn = .FoundFiles(i)
  30.         NyttNavn = Left(GammeltNavn, (Len(GammeltNavn) - 3)) & ".txt"
  31.         Name GammeltNavn As NyttNavn
  32.  
  33.         DoCmd.TransferText acImportFixed, "maskinpåfylling", "tbl maskinpåfylling", NyttNavn, False, ""
  34.  
  35.         Kill NyttNavn

This works fine but one thing. That is that i need to get the text file's creation date from the file properties.
Is there any way to do this?
Jun 10 '08 #1
3 3203
janders468
112 Expert 100+
You can use the FileSystemObject to check the creation date. You can get a reference to it by setting a reference to Microsft Scripting Runtime (or you can use the CreateObject method to set a generic Object if you don't want to set a reference). The Function below will return what you want.
Expand|Select|Wrap|Line Numbers
  1. Public Function GetCreateDate(Path As String) as Date
  2.     Dim fso As Scripting.FileSystemObject
  3.     Dim fsoFile As Scripting.File
  4.     Set fso = New Scripting.FileSystemObject
  5.     Set fsoFile = fso.GetFile(Path)
  6.     GetCreateDate = fsoFile.DateCreated
  7. End Function
  8.  
Jun 10 '08 #2
MrDeej
157 100+
Thank you!

I will look into this by next week :)
Jun 13 '08 #3
ADezii
8,834 Expert 8TB
The simplest method of retrieving a File's Date and Time of Creation or Last Modified Date is to use the intrinsic FileDateTime() Function, as in:
Expand|Select|Wrap|Line Numbers
  1. Dim varFileStamp
  2.  
  3. varFileStamp = FileDateTime("C:\Windows\System32\Wups.dll")
  4.  
  5. Debug.Print varFileStamp
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. 7/30/2007 7:18:40 PM 
  1. If the File can be modified, you will not want to use this approach, since it will return the Last Modified Date and not the actual Date on which it was Created.
  2. Incorporating this into your existing code should be a simple matter.
Jun 13 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: [ EuGeNe ] | last post by:
Hi all, I would like to write a script that downloads one file from a ftp server if the file creation date satisfy a condition. I can't figure out how to find from a ftp server what is the...
2
by: David Fickbohm | last post by:
People, I am trying to determine the creation date of files in a folder. I am using the following code to find the folder and confirm that files exist in the folder. If someone could give me an...
7
by: Marius III | last post by:
Hi there, I want to get the file version of a file in PHP. Do somebody have the code for this? Thanks alot!
8
by: Eddie Suey | last post by:
I want to add a new line to the begining of a text file. I dont want to write over existing data. How do I do this? the file is about 7 mb.
7
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
6
by: KoRnDragon | last post by:
I know about getlastmod() but is there one for created date? If not is there some other way of getting the created date of a file?
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
5
by: Andrus | last post by:
I'm creating a database Winforms application using VCS Express 2005 I have some large lookup tables (may be up to 500000 records) which contains name and id and are stored in sql server. I...
3
by: Radu | last post by:
Hi. I have the following problem - I need to build a user-control in asp.net (an ascx) to somehow allow the users to search by first name or last name among a big (~10.000 records) email addresses...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.