Solved

retrivieve name of last file created in directory

Posted on 2003-10-31
2
137 Views
Last Modified: 2010-05-01
i am writing an app for a business who takes pictures of people with a digital camera.
now i have the path where this digital camera stores this picture.
what i need to know is how can i find out which file was last created (thus the pic that was just taken) so that i can link the picture with that transaction and just copy the title of the picture to the database.
i also need a way to copy this file (in vb) to my c:\clientpics folder

or am i seeing this whole picture from a horrible perspective.
im using vb6 and its a sony camera.
0
Comment
Question by:jxharding
2 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 20 total points
ID: 9657658
If you add a FileList box and a command button to a form,you can try this:


Private Sub Form_Load()
File1.Path = "C:\CameraPics"
End Sub

Private Sub Command1_Click()
Dim LastDate As Date, LastFile As String, LastTitle As String
Dim CurFileDate As Date
Dim i As Integer

File1.Refresh

For i = 0 To File1.ListCount - 1
CurFileDate = FileDateTime(File1.Path & "\" & File1.List(i))

If CurFileDate > LastDate Then
    LastDate = CurFileDate
    LastFile = File1.Path & "\" & File1.List(i)
End If
Next i

' for testing
MsgBox LastFile

' get the filename
LastTitle = Mid$(LastFile, InStrRev(LastFile, "\") + 1)

' for testing
MsgBox LastTitle

' copy the file
FileCopy LastFile, "C:\Clientpics\" & LastTitle

End Sub
0
 

Author Comment

by:jxharding
ID: 9658423
vinnyd you are the man,
i learned a lot out of this which i can apply to future programming
sorry for the little points, but i live in a third world country called south africa
and one months e-e subscribtion = this weeks bread money :)

ps i will also be applying thsi to the scanner for clients who need to produce Identification documents
thanx!

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

680 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