Solved

retrivieve name of last file created in directory

Posted on 2003-10-31
2
134 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now