Hi
I have some code that checks if a file exists, its file size, creation date and date modified. The code works fine..however..
I need to import the file it is checking and that file can sometimes take up to 30 minutes to complete its posting. In fact I used the code to check it the other day and the code showed that it exists, its creation/modifed date and also its file size - however, the file size was what it was at that moment I ran the code. If I immediately re-run the code, the file size changes - obviously due to the fact that the file is still posting (and growing due to the date being posted to it). Also note that the (completed) file size will vary each day the file is posted
So, what I would like to know is, is their a way to check to see if a file has completed posting? Something akin to .filecreated like .filecompleted (yes or no) type thing?
Any help is appreciated. Here is the code:
Public Sub sub_chk_files2()
Dim obj_fs As Object
Dim obj_folder As Object
Dim obj_files As Object
Dim obj_f1 As Object
Dim db As DAO.Database
Dim str_fp As String
Dim str_fd As String
Dim str_fqfp As String
Dim str_date As String
Dim str_prod As String
Dim int_mod_dt As Integer 'number of days (from current day) that defines the date - in the file name - of the ITG file that is to be imported..
Dim int_count_files As Integer
Dim str_import_file_name As String
Dim lng_file_size As Long
Set db = CurrentDb
str_fp = "C:\01_reporting\"
Set obj_fs = CreateObject("scripting.filesystemobject")
Set obj_folder = obj_fs.getfolder(str_fp)
Set obj_files = obj_folder.files
For Each obj_f1 In obj_files
If obj_f1.Name = "data2.csv" Then
str_import_file_name = obj_f1.Name
str_fqfp = str_fp & str_import_file_name
lng_file_size = FileLen(str_fqfp) / 1000
MsgBox "File " & str_import_file_name & " was created on " & obj_f1.DateCreated & " File size = " & lng_file_size & " File Modified on " & obj_f1.DatelastModified
End If
Next
End Sub
I have some code that checks if a file exists, its file size, creation date and date modified. The code works fine..however..
I need to import the file it is checking and that file can sometimes take up to 30 minutes to complete its posting. In fact I used the code to check it the other day and the code showed that it exists, its creation/modifed date and also its file size - however, the file size was what it was at that moment I ran the code. If I immediately re-run the code, the file size changes - obviously due to the fact that the file is still posting (and growing due to the date being posted to it). Also note that the (completed) file size will vary each day the file is posted
So, what I would like to know is, is their a way to check to see if a file has completed posting? Something akin to .filecreated like .filecompleted (yes or no) type thing?
Any help is appreciated. Here is the code:
Public Sub sub_chk_files2()
Dim obj_fs As Object
Dim obj_folder As Object
Dim obj_files As Object
Dim obj_f1 As Object
Dim db As DAO.Database
Dim str_fp As String
Dim str_fd As String
Dim str_fqfp As String
Dim str_date As String
Dim str_prod As String
Dim int_mod_dt As Integer 'number of days (from current day) that defines the date - in the file name - of the ITG file that is to be imported..
Dim int_count_files As Integer
Dim str_import_file_name As String
Dim lng_file_size As Long
Set db = CurrentDb
str_fp = "C:\01_reporting\"
Set obj_fs = CreateObject("scripting.filesystemobject")
Set obj_folder = obj_fs.getfolder(str_fp)
Set obj_files = obj_folder.files
For Each obj_f1 In obj_files
If obj_f1.Name = "data2.csv" Then
str_import_file_name = obj_f1.Name
str_fqfp = str_fp & str_import_file_name
lng_file_size = FileLen(str_fqfp) / 1000
MsgBox "File " & str_import_file_name & " was created on " & obj_f1.DateCreated & " File size = " & lng_file_size & " File Modified on " & obj_f1.DatelastModified
End If
Next
End Sub