Solved

retrivieve name of last file created in directory

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now