IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

[Fichier Textes]Scruter fichier texte volumineux


Sujet :

VB 6 et antérieur

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 69
    Points : 59
    Points
    59
    Par défaut [Fichier Textes]Scruter fichier texte volumineux
    bonjour

    Je voudrais savoir si il existe un moyen rapide et effficace afin de scruter periodiquement un fichier texte(fichier syslog) afin de detecter l'ajour d'une nouvelle entrée.
    La methode classique serait de sauvegarder a chaque intervalle le nbr de lignes de mon fichier puis de tester.ca me parrait impeu tiré par les cheuveux
    Merci d'avance

  2. #2
    Expert éminent
    Avatar de ThierryAIM
    Homme Profil pro
    Inscrit en
    Septembre 2002
    Messages
    3 673
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2002
    Messages : 3 673
    Points : 8 524
    Points
    8 524
    Par défaut
    et tester la taille du fichier ?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 69
    Points : 59
    Points
    59
    Par défaut
    Mouais.....effectivement..mais je serais tjrs obligé de lire la totalité du fichier pour acceder a la derniere ligne
    en fait je doit modifier une appli qui anterieurement recevait des données sur le port COM(les données arrivaient vers un port serie, donc pas de soucis...ca marche tout seul).Désormais je dois lire dans un syslog....et en plus, distant...
    Merci

  4. #4
    Expert éminent sénior
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 091
    Points : 16 616
    Points
    16 616
    Par défaut
    sur une frm
    un label (LabLargeFont) (oublié au premier envoi)
    Un commandialog
    un commandbutton
    un listbox

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    Option Explicit
    Dim Chemin, Fichier, Resultat As String
    Dim NamIndx(34) As String
    Dim T, U As Byte
    Dim LargMin, HautMin As Integer
     
    Private Sub Form_Resize()
    If Me.WindowState <> vbMinimized Then
     If Me.WindowState = vbNormal Then
      If Me.Height < 1035 Then Me.Height = 1035
      If Me.Width < 2670 Then Me.Width = 2670
     End If
     List1.Height = (Me.Height - List1.Top) - (List1.Left * 8)
     List1.Width = Me.Width - (List1.Left * 4)
    End If
    End Sub
     
    Private Sub Form_Load()
    NamIndx(0) = "Name": NamIndx(1) = "Size": NamIndx(2) = "Type"
    NamIndx(3) = "Date Modified": NamIndx(4) = "Date Created": NamIndx(5) = "Date Accessed"
    NamIndx(6) = "Attributes": NamIndx(7) = "Status": NamIndx(8) = "Owner"
    NamIndx(9) = "Author": NamIndx(10) = "Title": NamIndx(11) = "Subject"
    NamIndx(12) = "Category": NamIndx(13) = "Pages": NamIndx(14) = "Comments"
    NamIndx(15) = "Copyright": NamIndx(16) = "Artist": NamIndx(17) = "Album Title"
    NamIndx(18) = "Year": NamIndx(19) = "Track Number": NamIndx(20) = "Genre"
    NamIndx(21) = "Duration": NamIndx(22) = "Bit Rate": NamIndx(23) = "Protected"
    NamIndx(24) = "Camera Model": NamIndx(25) = "Date du cliché": NamIndx(26) = "Dimensions"
    NamIndx(27) = "Not used": NamIndx(28) = "Not used": NamIndx(29) = "Not used"
    NamIndx(30) = "Company": NamIndx(31) = "Description": NamIndx(32) = "File Version"
    NamIndx(33) = "Product Name": NamIndx(34) = "Product Version"
    U = 0
    For T = 0 To 34
     If Len(NamIndx(T)) > U Then U = Len(NamIndx(T))
    Next T
    U = U + 1
    For T = 0 To 34
     NamIndx(T) = NamIndx(T) & String$(U - Len(NamIndx(T)), " ") & ": "
     If T < 10 Then NamIndx(T) = " " & NamIndx(T)
    Next T
    List1.Clear
    End Sub
     
    Private Sub Command1_Click()
    CommonDialog1.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
    CommonDialog1.Flags = CommonDialog1.Flags + cdlOFNPathMustExist + cdlOFNExplorer
    CommonDialog1.CancelError = True
    On Error Resume Next
    CommonDialog1.ShowOpen
    If Err.Number <> 0 Then On Error GoTo 0: Exit Sub
    Fichier = CommonDialog1.FileTitle
    Chemin = Left$(CommonDialog1.FileName, Len(CommonDialog1.FileName) - Len(Fichier))
    informationsFichier
    LargMin = (LargMin + 1) * LabLargeFonte.Width
    HautMin = (240 * (List1.ListCount - 1))
    'redimenssionnes si besoin
    If List1.Height < HautMin Then
     List1.Height = HautMin
     Me.Height = List1.Height + List1.Top + (List1.Left * 8)
    End If
    If List1.Width < LargMin Then
     List1.Width = LargMin
     Me.Width = LargMin + (List1.Left * 4)
    End If
    End Sub
     
    Public Sub informationsFichier()
    'recuperé sur ce forum pour avoir les infos que tu recherche
    'necessite d'activer reference Microsoft Shell Controls and Automation
     
    Dim objShell As Shell
    Dim objFolder As Folder
    Dim strFileName As FolderItem
     
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.NameSpace(Chemin) 'adapter le chemin
    Set strFileName = objFolder.Items.Item(Fichier) 'adapter le fichier
    List1.Clear: LargMin = 0
    For T = 0 To 34
     If objFolder.GetDetailsOf(strFileName, T) <> "" Then
      List1.AddItem CStr(T) & " " & NamIndx(T) & Trim$(objFolder.GetDetailsOf(strFileName, T))
      If LargMin < Len(List1.List(List1.NewIndex)) Then LargMin = Len(List1.List(List1.NewIndex))
     End If
    Next
    Set objShell = Nothing: Set objFolder = Nothing: Set strFileName = Nothing
    End Sub
    "Date Modified": NamIndx(4)
    en retenant la derniere date/heure du fichier et en la comparant par la suite
    If OldDate <> DateDernierAppel then
    'comparer ou/et le fichier à ete modifié

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 69
    Points : 59
    Points
    59
    Par défaut
    Merci pour vos reponses
    C bon mais il faudrait que ca me retourne une date plus precise...car si mon fichier est modifié 2 fois pendant une minute, mon traitement sera faux.
    dateDernieremodif retourne par exemple 17/10/200 13:30
    il me faudrait au moins les secondes...

    Merci

  6. #6
    Inactif  
    Avatar de jmfmarques
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    3 784
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 3 784
    Points : 4 674
    Points
    4 674
    Par défaut
    Tu auras plus qu'il ne t'en faut avec ceci !
    ToutApi
    Fichiers attachés Fichiers attachés

  7. #7
    Expert éminent
    Avatar de bidou
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2002
    Messages
    3 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 055
    Points : 7 962
    Points
    7 962
    Par défaut
    y a des moments où vous me faites un peu peur les gars

    normalement FileDateTime devrait le faire. Par exemple

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Private Sub Command1_Click()
     
     If DateDiff("s", Me.Label1.Caption, FileDateTime("d:\user\test.txt")) > 0 Then
        MsgBox "Modifié"
     End If
     
    End Sub
     
    Private Sub Form_Load()
     
    Me.Label1.Caption = FileDateTime("d:\user\test.txt")
     
    End Sub

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 69
    Points : 59
    Points
    59
    Par défaut
    BIDOU : +1

    Merci a tous

  9. #9
    Membre expérimenté
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2006
    Messages
    1 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Argentine

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Octobre 2006
    Messages : 1 173
    Points : 1 418
    Points
    1 418
    Par défaut
    C'est pas propre tout ça :>

    Ouvrir un fichier ne veut pas dire ajouter une ligne à la fin ...

  10. #10
    Expert éminent
    Avatar de bidou
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2002
    Messages
    3 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 055
    Points : 7 962
    Points
    7 962
    Par défaut
    Citation Envoyé par Vld44
    C'est pas propre tout ça :>

    Ouvrir un fichier ne veut pas dire ajouter une ligne à la fin ...
    Certes, mais comme on ne regarde pas la date d'ouverture non plus, ce n'est pas trop grave...

  11. #11
    Membre expérimenté
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2006
    Messages
    1 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Argentine

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Octobre 2006
    Messages : 1 173
    Points : 1 418
    Points
    1 418
    Par défaut
    peu importe, même si c'est la date de sauvegarde, ce n'est pas parcequ'il y a eu une sauvegarde que le fichier a changé de contenu ...

  12. #12
    Expert éminent
    Avatar de bidou
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2002
    Messages
    3 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 055
    Points : 7 962
    Points
    7 962
    Par défaut
    sur un fichier en général non, mais sur un fichier de log si.
    Un fichier de log c'est un fichier qu'une apllication ouvre pour ajout, ajoutes des trucs et referme.

  13. #13
    Rédacteur
    Avatar de omen999
    Profil pro
    Inscrit en
    Février 2006
    Messages
    1 299
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 1 299
    Points : 3 554
    Points
    3 554
    Par défaut
    on peut aussi utiliser le flag archive avec SetAttr

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 15
    Dernier message: 28/11/2008, 17h57
  2. Réponses: 3
    Dernier message: 05/04/2005, 11h52
  3. [Fichier] Lire un fichier texte long
    Par _Eric_ dans le forum Entrée/Sortie
    Réponses: 9
    Dernier message: 18/08/2004, 15h22
  4. [ Vector Fichier ] Vector dans fichier texte
    Par geegee dans le forum Langage
    Réponses: 5
    Dernier message: 21/05/2004, 13h56
  5. Sauvegarde des attributs de texte en fichier ini
    Par Raylemon dans le forum Langage
    Réponses: 2
    Dernier message: 06/09/2003, 21h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo