Solved

retrivieve name of last file created in directory

Posted on 2003-10-31
2
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

734 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