Skip to main content

AccessTr.neT


Klasördeki Son Eklenen Dosyayı Getirmek

Klasördeki Son Eklenen Dosyayı Getirmek

#8
ilk mesajdaki kodun son hali şöyle oldu
Private Sub findLastExcel()
    Dim lastFile As String
    lastFile = newestFile("C:\_egitim\", "*.xls", True)
    If (InStr(lastFile, ",") > 0) Then
        Me.txtLastFile = Split(lastFile, ",")(0)
        Me.txtLastFile.ControlTipText = Split(lastFile, ",")(1)
    Else
        Me.txtLastFile = lastFile
    End If
   
End Sub


Function newestFile(Directory As String, Optional FileSpec As String = "*.*", Optional bringDate As Boolean = False) As String
On Error GoTo Err_hata
    Dim result As String
    result = ""
   
    Dim FileName As String
    Dim MostRecentFile As String
    Dim MostRecentDate As Date
   
    FileName = Dir(Directory & FileSpec)
   
    If FileName <> "" Then
        MostRecentFile = FileName
        MostRecentDate = FileDateTime(Directory & FileName)
        Do While FileName <> ""
            If FileDateTime(Directory & FileName) > MostRecentDate Then
                MostRecentFile = FileName
                MostRecentDate = FileDateTime(Directory & FileName)
            End If
            FileName = Dir
        Loop
    End If
   
   
    result = MostRecentFile
    If (bringDate) Then result = result & "," & MostRecentDate
   
Exit_kod:
    newestFile = result
    Exit Function

Err_hata:
    result = ""
    MsgBox Err.Description
    Resume Exit_kod
End Function

8. mesajdaki kod içerisine 2. mesajdaki kodu entegre etsek
yani 1.kod ile bulunan dosya aynı zamanda dosya adındaki tarih olarak da son tarih ise
şartını nasıl koyabiliriz
@benbendedeilem
Son Düzenleme: 22/05/2020, 11:10, Düzenleyen: accessman.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
RE: Klasördeki Son Eklenen Dosyayı Getirmek - Yazar: accessman - 22/05/2020, 11:07