Solved

retrivieve name of last file created in directory

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 70
VB error "Type mismatch" 2 54
using web browser with BING 40 120
Spell Check in VB6 13 112
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

770 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