?
Solved

File Size and Date

Posted on 2003-03-11
5
Medium Priority
?
139 Views
Last Modified: 2010-05-01
I've got the following code in my programm:

m_strFilePath = File2.Path & "\" & "List.txt"
  Open m_strFilePath For Output As #1
  For intIndex = 0 To File2.ListCount - 1
       Print #1, File2.List(intIndex)
  Next intIndex
  Close #1
End If

This writes a list.txt in the directory where all the files are, with the files that are in the same directory.
Now my questions is how to ad to this procedure a way to get the filesize an date, and add that to the same file like:
goodmorning.jpg     12323     12/07/2003
               ^^^^^     ^^^^^ These should be spaces or tabs

Is it possible to do that?
And could you give a code example?

Kind Regards, Joleen.
0
Comment
Question by:Joleen
5 Comments
 
LVL 7

Expert Comment

by:mquiroz
ID: 8114894
check out this code:

put this on a module:

Option Explicit

Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Public Type WIN32_FIND_DATA
 dwFileAttributes  As Long
 ftCreationTime    As FILETIME
 ftLastAccessTime  As FILETIME
 ftLastWriteTime   As FILETIME
 nFileSizeHigh     As Long
 nFileSizeLow      As Long
 dwReserved0       As Long
 dwReserved1       As Long
 cFileName         As String * 100
 cAlternate        As String * 14
End Type

Public Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" _
  (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long



and put this on a new proyect's main form:

Private Sub Form_Load()
Dim filedata As WIN32_FIND_DATA
Dim retval As Double
retval = FindFirstFile("c:\autoexec.bat", filedata)
MsgBox filedata.nFileSizeLow
End Sub

make some experients and enjoy!!!!
0
 
LVL 34

Expert Comment

by:arbert
ID: 8114896
Look at FileDateTime() function in help.

Basically, you call the function with the filename and path:

m_strFilePath = File2.Path & "\" & "List.txt"
 Open m_strFilePath For Output As #1
 For intIndex = 0 To File2.ListCount - 1
      Print #1, File2.List(intIndex) & " " & filedatetime(file2.list(intindex))
     
 Next intIndex
 Close #1
End If





There is a very CLEAR example in the VB help.....

Brett
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 200 total points
ID: 8114938
Open m_strFilePath For Output As #1
For intIndex = 0 To File2.ListCount - 1
    Print #1, File2.List(intIndex), FileLen(File2.Path & "\" & File2.List(intIndex)), Format(FileDateTime(File2.Path & "\" & File2.List(intIndex)), "mm/dd/yyyy")
Next intIndex
Close #1
0
 

Author Comment

by:Joleen
ID: 8115217
PaulHews,
I do not understand how you created the spaces in the lines, can you explain that?
For the other guys, thank you very much, it triggers al lot of idea's, but I have to reward PaulHews, because his solution worked instantly.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8115413
If I do this:

Print #1, x, y, z

then the print statement will print the variables x, y and z in the file with a tab character separating them.
0

Featured Post

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.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

621 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