Recuperer le nom du dernier fichier entré

beny100 Messages postés 213 Date d'inscription vendredi 17 novembre 2006 Statut Membre Dernière intervention 1 avril 2009 - 24 août 2008 à 16:42
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 - 24 août 2008 à 18:00
bonsoir a tous.
j'ai un soucis, en effet je voudrais recuperer le nom du dernier fichier copié dans mon  repertoire.

j'utilise directory.getfiles, mais je ne sais plus comment y faire après
aidez moi s'il vous plait

 

3 réponses

gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
24 août 2008 à 17:06
My

.Computer.FileSystem.GetFileInfo(


"mondir"

).LastAccessTime

ou
 

My.Computer.FileSystem.GetFileInfo(
"mondir").LastWriteTime
à toi de voir

Bonjour chez vous !
0
beny100 Messages postés 213 Date d'inscription vendredi 17 novembre 2006 Statut Membre Dernière intervention 1 avril 2009
24 août 2008 à 17:19
en effet ca ne me donne rien . rien qu'une date qui ne coorespond a aucune date d'entrée dun des fichers.
0
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
24 août 2008 à 18:00
moi j'utilise cela pour faire un backup  :)

Private
Sub backup(
ByVal srcdir
As
String,
ByVal destDrive
As
String)

Dim src, dest, log
As
Stringlog =

String.Empty

For
Each file
As
String
In
My.Computer.FileSystem.GetFiles(srcdir, FileIO.SearchOption.SearchAllSubDirectories,
"*.*")src = file

dest = Replace(file,

"C:", destDrive)

Try

If IO.File.Exists(dest)
Then

If
Date.Compare(
My.Computer.FileSystem.GetFileInfo(src).LastWriteTime,
My.Computer.FileSystem.GetFileInfo(dest).LastWriteTime) = 0
Then

'le fichier est le même à 99,999%

Else

'overwrite

My.Computer.FileSystem.CopyFile(src, dest,
True)

End
If

Else

'copy

My.Computer.FileSystem.CopyFile(src, dest,
False)

End
If

Catch ex
As Exceptionlog = log & Now.ToShortDateString &

" " & Now.ToLongTimeString &
"." & Now.Millisecond & ex.Message & vbCrLf

End
Try

If ProgressBar1.Value = 99 Then ProgressBar1.Value 1ProgressBar1.Value ProgressBar1.Value + 1

Application.DoEvents()

Next

If log =
String.Empty
Then

' MsgBox("Pas d'erreurs", MsgBoxStyle.Information)

Else

My.Computer.FileSystem.WriteAllText(Application.StartupPath &
"" & Today.ToLongDateString &
".log", log,
True)

If MessageBox.Show(
"il y a eu des erreurs," & vbCrLf &
"voulez vous voir le log maintenant?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Error) = Windows.Forms.DialogResult.Yes
ThenProcess.Start(

"notepad.exe", Application.StartupPath &
"" & Today.ToLongDateString &
".log")

End
If

End
If

End
Subavec ça tu devrais trouver

Bonjour chez vous !
0
Rejoignez-nous